19declare(strict_types=1);
23use InvalidArgumentException;
37 return new ArrayIterator($this->elements);
47 return $this->
get($offset);
52 if (!isset($offset)) {
58 $this->
set($offset, $value);
63 $this->
remove($offset);
68 return \count($this->elements);
73 $this->elements[] = $element;
76 public function remove($key):
void
79 throw new InvalidArgumentException(
"Key $key does not exist.");
81 unset($this->elements[$key]);
86 $key = array_search($element, $this->elements,
true);
88 throw new InvalidArgumentException(
'Could not find an key for the passed element.');
90 unset($this->elements[$key]);
95 return isset($this->elements[$key]);
100 $key = array_search($element, $this->elements,
true);
101 if ($key ===
false) {
102 throw new InvalidArgumentException(
'Could not find an key for the passed element.');
109 $this->elements = [];
114 return \in_array($element, $this->elements,
true);
119 return $this->elements[$key] ??
null;
124 $this->elements[$key] = $value;
129 return empty($this->elements);
134 return array_keys($this->elements);
139 return array_values($this->elements);
144 $filtered = array_filter($this->elements, $callable);
145 return new self($filtered);
150 $sliced = \array_slice($this->elements, $offset, $length,
true);
151 return new self($sliced);
156 return $this->elements;
161 if (!$other instanceof
self) {
166 $other = $other->toArray();
171 return $self === $other;
add(AutoresponderDto $element)
offsetSet(int $offset, AutoresponderDto $value)
contains(AutoresponderDto $element)
getKey(AutoresponderDto $element)
__construct(private array $elements=[])
offsetExists(int $offset)
removeElement(AutoresponderDto $element)
slice(int $offset, ?int $length=null)
filter(callable $callable)