37 use IteratorAggregate;
39 class Collection implements ArrayAccess, Countable, IteratorAggregate
66 public function getField($name, $default =
null)
68 if (isset($this->items[$name])) {
69 return $this->items[$name];
88 return $this->
getField($name, $default);
98 return array_keys($this->items);
131 return array_map(
function ($value) {
143 public function map(\Closure $callback)
145 return new static(array_map($callback, $this->items, array_keys($this->items)));
157 return json_encode($this->
asArray(), $options);
167 return count($this->items);
177 return new ArrayIterator($this->items);
189 return array_key_exists($key, $this->items);
201 return $this->items[$key];
215 $this->items[] = $value;
217 $this->items[$key] = $value;
230 unset($this->items[$key]);