data = $data; } elseif ($data instanceof \Traversable) { $this->data = iterator_to_array($data, true); } else { throw new \InvalidArgumentException('The ArrayContainer requires either an array or an array-like object'); } $this->delegateLookupContainer = $delegateLookupContainer ?: $this; } public function get($id) { if (isset($this->data[$id])) { try { if ($this->data[$id] instanceof \Closure) { $this->data[$id] = call_user_func($this->data[$id], $this->delegateLookupContainer); } } catch (\Exception $prev) { throw ContainerException::fromPrevious($id, $prev); } return $this->data[$id]; } else { throw NotFoundException::fromPrevious($id); } } public function has($identifier) { return isset($this->data[$identifier]); } public function offsetExists($offset) { return isset($this->data[$offset]); } public function offsetGet($offset) { return $this->get($offset); } public function offsetSet($offset, $value) { $this->data[$offset] = $value; } public function offsetUnset($offset) { unset($this->data[$offset]); } }