| Total Complexity | 13 |
| Total Lines | 64 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class Collection implements ArrayAccess, JsonSerializable, Stringable |
||
| 10 | { |
||
| 11 | public function __construct(protected $items = []) |
||
| 12 | { |
||
| 13 | $this->items = \array_values($this->items); |
||
| 14 | } |
||
| 15 | |||
| 16 | public function join(string $separator = ' '): string |
||
| 17 | { |
||
| 18 | return implode($separator, $this->all()); |
||
| 19 | } |
||
| 20 | |||
| 21 | public function map(callable $callback): Collection |
||
| 24 | } |
||
| 25 | |||
| 26 | public function all(): array |
||
| 27 | { |
||
| 28 | return \array_values($this->items); |
||
| 29 | } |
||
| 30 | |||
| 31 | public function toArray(): array |
||
| 32 | { |
||
| 33 | return $this->all(); |
||
| 34 | } |
||
| 35 | |||
| 36 | public function toJson(int $options = 0): string |
||
| 37 | { |
||
| 38 | return json_encode($this->all(), $options); |
||
| 39 | } |
||
| 40 | |||
| 41 | public function __toString() |
||
| 42 | { |
||
| 43 | return $this->join(); |
||
| 44 | } |
||
| 45 | |||
| 46 | public function offsetExists(mixed $offset): bool |
||
| 49 | } |
||
| 50 | |||
| 51 | public function offsetGet(mixed $offset): mixed |
||
| 52 | { |
||
| 53 | return $this->items[$offset] ?? null; |
||
| 54 | } |
||
| 55 | |||
| 56 | public function offsetSet(mixed $offset, mixed $value): void |
||
| 62 | } |
||
| 63 | } |
||
| 64 | |||
| 65 | public function offsetUnset(mixed $offset): void |
||
| 66 | { |
||
| 67 | unset($this->items[$offset]); |
||
| 68 | } |
||
| 69 | |||
| 70 | public function jsonSerialize(): mixed |
||
| 73 | } |
||
| 74 | } |
||
| 75 |