public function __construct(\Iterator $iterator, $filter)
 {
     Contracts::ensureCallable($filter);
     $this->iterator = $iterator;
     $this->filter = $filter;
     $this->findCurrent();
 }
 public function __construct(\Iterator $iterator, $mapper)
 {
     Contracts::ensureCallable($mapper);
     $this->iterator = $iterator;
     $this->mapper = $mapper;
     $this->prepareCurrent();
 }
 public function __construct(\Iterator $iterator, $mapper)
 {
     Contracts::ensureCallable($mapper);
     $this->flattingIterator = $iterator;
     $this->mapper = $mapper;
     parent::__construct($this->prepareCurrentIterator()->orElse(new \ArrayIterator(array())), function ($element) {
         return $element;
     });
 }
Esempio n. 4
0
 /**
  * @param callback $mapper
  *
  * @return MapBuilder
  */
 public function mapElements($mapper)
 {
     Contracts::ensureCallable($mapper);
     if ($this->map instanceof \SplObjectStorage) {
         foreach ($this->map as $key) {
             $this->map[$key] = call_user_func($mapper, $this->map[$key]);
         }
     } else {
         foreach ($this->map as $key => $element) {
             $this->map[$key] = call_user_func($mapper, $element);
         }
     }
     return $this;
 }
Esempio n. 5
0
 /**
  * {@inheritDoc}
  */
 public function eachBy($processor)
 {
     Contracts::ensureCallable($processor);
     return $this;
 }
Esempio n. 6
0
 /**
  * {@inheritDoc}
  */
 public function eachBy($processor)
 {
     Contracts::ensureCallable($processor);
     call_user_func($processor, $this->data);
     return $this;
 }
Esempio n. 7
0
 public function __construct($comparator)
 {
     Contracts::ensureCallable($comparator);
     $this->comparator = $comparator;
 }