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; }); }
/** * @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; }
/** * {@inheritDoc} */ public function eachBy($processor) { Contracts::ensureCallable($processor); return $this; }
/** * {@inheritDoc} */ public function eachBy($processor) { Contracts::ensureCallable($processor); call_user_func($processor, $this->data); return $this; }
public function __construct($comparator) { Contracts::ensureCallable($comparator); $this->comparator = $comparator; }