23 private function __construct(array $items = []) {
24 $this->items = $items;
31 return in_array(
$item, $this->items,
true);
37 #[\ReturnTypeWillChange] 39 return count($this->items);
45 #[\ReturnTypeWillChange] 56 foreach ($this->items as
$item) {
68 #[\ReturnTypeWillChange] 69 public function key() {
70 return key($this->items);
76 public function map(callable $mapper) {
78 foreach ($this->items as
$item) {
88 #[\ReturnTypeWillChange] 90 return next($this->items);
96 #[\ReturnTypeWillChange] 104 #[\ReturnTypeWillChange] 106 return key($this->items) !== null;
117 return new self($items);
static fromArray(array $items)
Factory function for converting from an array to a ton of items.
map(callable $mapper)
Take items of the collection and return a new collection with all the items having the $mapper applie...
Uses native PHP array to implement the Collection interface.
contains($item)
Returns true iff the item is in this collection at least once.The object or value to check forboolean...
filter(callable $filter)
Returns a new collection only containing the elements which pass the filter.Receives an item...
A read-only interface to a (possibly mutable) group of items.