Ejemplo n.º 1
1
 function current()
 {
     $current = $this->_iterator->current();
     return $this->_pipe->process($current);
 }
 /**
  * Implentation of the Iterator SPL class for Rewind(), 
  * prepares the whole datasource for an entirely new iterator operation
  * 
  * @access public
  */
 public function rewind()
 {
     $this->datasource->rewind();
     //Process the transformers
     if ($this->valid()) {
         $this->transformedData = $this->transform($this->datasource->current(), $this->datasource->key());
     }
 }
Ejemplo n.º 3
0
 /**
  * Return the current element.
  *
  * @return  mixed
  */
 public function current()
 {
     if (null !== $this->_current) {
         return $this->_current;
     }
     $demuxer = $this->_demuxer;
     return $this->_current = $demuxer($this->_iterator->current());
 }
Ejemplo n.º 4
0
 public static function findMinMax(\Traversable $it, callback $extractor = null)
 {
     if ($extractor === null) {
         $extractor = function ($value) {
             return $value;
         };
     }
     $min = $max = $extractor($it->current());
     $it->next();
     $value = $extractor($it->current());
     while ($it->valid()) {
         if ($value > $max) {
             $max = $value;
         } elseif ($value < $min) {
             $min = $value;
         }
         $it->next();
         $value = $it->current();
     }
     return array($min, $max);
 }
Ejemplo n.º 5
0
 /**
  * Return the current element.
  *
  * @return  mixed
  */
 public function current()
 {
     return $this->_iterator->current();
 }
Ejemplo n.º 6
0
 /**
  * Filter out duplicate items by advancing to the next ones
  */
 protected function filterViaNext()
 {
     while ($this->valid()) {
         $rel = $this->iter->current();
         // path relative to given directory
         $path = $this->params['dir'] . "/{$rel}";
         // full storage path
         if ($this->backend->isSingleShardPathInternal($path)) {
             break;
             // path is only on one shard; no issue with duplicates
         } elseif (isset($this->multiShardPaths[$rel])) {
             // Don't keep listing paths that are on multiple shards
             $this->iter instanceof Iterator ? $this->iter->next() : next($this->iter);
         } else {
             $this->multiShardPaths[$rel] = 1;
             break;
         }
     }
 }
Ejemplo n.º 7
0
 /**
  * Returns the current value from the iterator
  *
  * @return Mixed
  */
 function current()
 {
     return isset($this->offset) ? $this->inner->current() : NULL;
 }
Ejemplo n.º 8
0
 /**
  * Implentation of the Iterator SPL class for Current(), 
  * returns the current element of the data source
  * Returns null if nothing found
  * 
  * @access public
  *
  * @return mixed Current value of the iterator
  */
 public function current()
 {
     return $this->datasource->current();
 }
Ejemplo n.º 9
0
 public function current()
 {
     return $this->input->current();
 }
Ejemplo n.º 10
0
/**
 * Example of applying a callback to capitalize the first letter.
 * 
 * Note that you must return TRUE from the callback function to continue
 * iterating. This can be useful if you wish to stop iteration under
 * certain conditions.
 *
 * @param   Iterator $it
 * @return  bool
 */
function addDbPrefix(Traversable $it, $prefix = 'test')
{
    echo $it[$it->key()] = $prefix . '_' . $it->current();
    echo PHP_EOL;
    return true;
}