Пример #1
0
 /**
  * @param \ArrayIterator $map
  */
 public function __construct(\ArrayIterator $map)
 {
     $this->map = $map;
     parent::__construct($this->map, function ($element) use($map) {
         return array($map->key(), $element);
     });
 }
 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;
     });
 }
 public function __construct(\SplObjectStorage $map)
 {
     $this->map = $map;
     $keyFinder = function ($key) {
         return $key instanceof NotObjectKey ? $key->key : $key;
     };
     parent::__construct($this->map, function ($key) use($keyFinder, $map) {
         return array($keyFinder($key), $map[$key]);
     });
 }
Пример #4
0
 public function __construct(Pairs $pairs, $part)
 {
     if (!in_array($part, array(static::PART_KEY, static::PART_ELEMENT))) {
         throw new \InvalidArgumentException('Unknown part.');
     }
     $this->pairs = $pairs;
     parent::__construct($this->pairs, function ($pair) use($part) {
         return $pair[$part];
     });
 }