Esempio n. 1
0
 public function valid()
 {
     if (!parent::valid()) {
         return false;
     }
     return $this->range->contains($this->current()->getKey());
 }
Esempio n. 2
0
 public function next()
 {
     $this->chunk = array();
     for ($i = 0; $i < $this->chunkSize && parent::valid(); $i++) {
         $this->chunk[] = parent::current();
         parent::next();
     }
 }
Esempio n. 3
0
 public function next()
 {
     $this->chunk = array();
     for ($i = 0; $i < $this->size && parent::valid(); ++$i) {
         $this->chunk[] = parent::current();
         parent::next();
     }
     $this->chunk ? $this->key++ : null;
 }
Esempio n. 4
0
 /**
  * @param \nochso\WriteMe\Document $document
  *
  * @return \SplFileInfo
  */
 private function findChangelog(Document $document)
 {
     $changelogName = $this->options->getValue('changelog.file');
     $searchDepth = $this->options->getValue('changelog.search-depth');
     $folder = dirname($document->getFilepath());
     $files = new \IteratorIterator(Finder::findFiles($changelogName)->from($folder)->limitDepth($searchDepth));
     $files->next();
     if (!$files->valid()) {
         throw new \RuntimeException(sprintf("Unable to find changelog '%s' in folder '%s'", $changelogName, $folder));
     }
     return $files->current();
 }
Esempio n. 5
0
 public function valid()
 {
     if (!parent::valid()) {
         return false;
     }
     if ($aKey = FsKey::createKey(parent::current())) {
         $this->aCurrentKey = $aKey;
         return true;
     } else {
         return false;
     }
 }
 /**
  * Get next bunch of validated rows.
  *
  * @return array|null
  */
 public function getNextBunch()
 {
     if (null === $this->_iterator) {
         $this->_iterator = $this->getIterator();
         $this->_iterator->rewind();
     }
     if ($this->_iterator->valid()) {
         $dataRow = $this->_iterator->current();
         $dataRow = Mage::helper('core')->jsonDecode($dataRow[0]);
         $this->_iterator->next();
     } else {
         $this->_iterator = null;
         $dataRow = null;
     }
     return $dataRow;
 }
Esempio n. 7
0
 /**
  * Get next bunch of validatetd rows.
  *
  * @return array|null
  */
 public function getNextBunch()
 {
     if (null === $this->_iterator) {
         $this->_iterator = $this->getIterator();
         $this->_iterator->rewind();
     }
     if ($this->_iterator->valid()) {
         $dataRow = $this->_iterator->current();
         $dataRow = unserialize($dataRow[0]);
         $this->_iterator->next();
     } else {
         $this->_iterator = null;
         $dataRow = null;
     }
     return $dataRow;
 }
 /**
  * Returns whether the current element is valid or not (as required by the
  * Iterator interface).
  *
  * @return bool true if the current element is valid; false otherwise
  */
 public function valid()
 {
     return $this->iterator->valid();
 }
Esempio n. 9
0
 public function valid()
 {
     echo $this->key . ') ' . __METHOD__ . PHP_EOL;
     return parent::valid();
 }
Esempio n. 10
0
 public function valid()
 {
     return parent::valid() && $this->it2->valid();
 }
    {
        echo __METHOD__ . "({$name})\n";
    }
}
$stmt = $db->query($SELECT, PDO::FETCH_CLASS, 'Test', array('WOW'));
$it = new IteratorIterator($stmt);
/* check if we can convert that thing */
/*** HINT: If YOU plan to do so remember not to call rewind() -> see below ***/
foreach ($it as $data) {
    var_dump($data);
}
$it->next();
/* must be allowed */
var_dump($it->current());
/* must return NULL */
var_dump($it->valid());
/* must return false */
class PDOStatementAggregate extends PDOStatement implements IteratorAggregate
{
    private function __construct()
    {
        echo __METHOD__ . "\n";
        $this->setFetchMode(PDO::FETCH_NUM);
        /* default fetch mode is BOTH, so we see if the ctor can overwrite that */
    }
    function getIterator()
    {
        echo __METHOD__ . "\n";
        $this->execute();
        return new IteratorIterator($this, 'PDOStatement');
    }
Esempio n. 12
0
 /**
  * Returns whether the iterator currently has a valid value
  *
  * @return Boolean
  */
 public function valid()
 {
     $this->dumpStart(__FUNCTION__);
     $result = parent::valid();
     $this->dumpEnd(__FUNCTION__, $result);
     return $result;
 }
Esempio n. 13
0
 /**
  * Move to next element
  */
 public function next()
 {
     parent::next();
     ++$this->count;
     if (parent::valid()) {
         $this->advanceWindow();
     }
 }