本文整理汇总了PHP中Reader::next方法的典型用法代码示例。如果您正苦于以下问题:PHP Reader::next方法的具体用法?PHP Reader::next怎么用?PHP Reader::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reader
的用法示例。
在下文中一共展示了Reader::next方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: next
function next()
{
if (($this->_entity = fgets($this->_file_handler)) == false) {
throw new \Exception("Error: product failed on read");
}
if (($this->_entity = json_decode($this->_entity, true)) === null) {
throw new \Exception("Error: unrecognized type");
}
parent::next();
}
示例2: testGetClarkNoNS
function testGetClarkNoNS()
{
$input = <<<BLA
<?xml version="1.0"?>
<root />
BLA;
$reader = new Reader();
$reader->xml($input);
$reader->next();
$this->assertEquals('{}root', $reader->getClark());
}
示例3: next
function next()
{
if (($this->_entity = fgetcsv($this->_file_handler, 0, $this->_delimiter)) == false) {
throw new \Exception("Error: product failed on read");
}
// Handling blamk row
if (empty(implode($this->_entity))) {
throw new \Exception("Error: Record is empty");
}
$this->_entity = array_combine($this->_header, $this->_entity);
parent::next();
}
示例4: testParseInnerTree
/**
* @depends testMappedElement
*/
function testParseInnerTree()
{
$input = <<<BLA
<?xml version="1.0"?>
<root xmlns="http://sabredav.org/ns">
<elem1>
<elem1 />
</elem1>
</root>
BLA;
$reader = new Reader();
$reader->elementMap = ['{http://sabredav.org/ns}elem1' => function (Reader $reader) {
$innerTree = $reader->parseInnerTree(['{http://sabredav.org/ns}elem1' => function (Reader $reader) {
$reader->next();
return "foobar";
}]);
return $innerTree;
}];
$reader->xml($input);
$output = $reader->parse();
$expected = ['name' => '{http://sabredav.org/ns}root', 'value' => [['name' => '{http://sabredav.org/ns}elem1', 'value' => [['name' => '{http://sabredav.org/ns}elem1', 'value' => 'foobar', 'attributes' => []]], 'attributes' => []]], 'attributes' => []];
$this->assertEquals($expected, $output);
}
示例5: read
public function read()
{
static $seeked = 0;
static $currently_reading = false;
static $currently_skipping = false;
static $arrayPartial = array();
static $arraySkip = array();
$ignore = false;
while ($ret = parent::read()) {
$id = $this->getAttributeNs("id", self::XMLNS_XML);
$currentPartial = end($arrayPartial);
$currentSkip = end($arraySkip);
if (isset($this->partial[$id])) {
if ($currentPartial == $id) {
v("%s done", $id, VERBOSE_PARTIAL_READING);
unset($this->partial[$id]);
--$seeked;
$currently_reading = false;
array_pop($arrayPartial);
} else {
v("Starting %s...", $id, VERBOSE_PARTIAL_READING);
$currently_reading = $id;
++$seeked;
$arrayPartial[] = $id;
}
return $ret;
} elseif (isset($this->skip[$id])) {
if ($currentSkip == $id) {
v("%s done", $id, VERBOSE_PARTIAL_READING);
unset($this->skip[$id]);
$currently_skipping = false;
$ignore = false;
array_pop($arraySkip);
} else {
v("Skipping %s...", $id, VERBOSE_PARTIAL_READING);
$currently_skipping = $id;
$ignore = true;
$arraySkip[] = $id;
}
} elseif ($currently_skipping && $this->skip[$currently_skipping]) {
if ($currentSkip == $id) {
v("Skipping child of %s, %s", $currently_reading, $id, VERBOSE_PARTIAL_CHILD_READING);
} else {
v("%s done", $id, VERBOSE_PARTIAL_CHILD_READING);
}
$ignore = true;
} elseif ($currently_reading && $this->partial[$currently_reading]) {
if ($currentPartial == $id) {
v("Rendering child of %s, %s", $currently_reading, $id, VERBOSE_PARTIAL_CHILD_READING);
} else {
v("%s done", $id, VERBOSE_PARTIAL_CHILD_READING);
}
return $ret;
} elseif (empty($this->partial)) {
return false;
} else {
// If we are used by the indexer then we have no clue about the
// parents :)
if ($id && $this->parents) {
// If this id isn't one of our ancestors we can jump
// completely over it
if (!in_array($id, $this->parents)) {
parent::next();
}
}
$ignore = true;
}
}
return $ret;
}
示例6: initialize
/**
* Realiza la revision del archivo
*
* @param string $fileName
*/
protected function initialize(Reader $reader)
{
$this->checkCsvFile($reader->getFilename());
if (count($this->rules) === 0) {
throw new Exception(' No se puede revistar el documento sin antes haber definido reglas @ ' . __LINE__);
}
$index = $reader->getHeaders();
if (count($this->index) > 0) {
$faltan = array_diff($this->index, $index);
if (count($faltan)) {
$this->addError('Se detectaron columnas faltantes en el archivo, se necesitan ' . implode(', ', $this->index) . ' y se encontraron ' . implode(', ', $index) . ' Faltando ' . implode(', ', $faltan) . '');
}
}
$reader->rewind();
while ($reader->valid()) {
$this->applyRules($reader->current(), $reader->getLineNumber());
$reader->next();
}
}