| Total Complexity | 10 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php declare(strict_types = 1); |
||
| 15 | final class Queue implements Countable |
||
| 16 | { |
||
| 17 | public function __construct(/** @var array<Q> */ private array $items = []) |
||
| 18 | { |
||
| 19 | } |
||
| 20 | |||
| 21 | public function clear(): void |
||
| 24 | } |
||
| 25 | |||
| 26 | public function contains(mixed $item): bool |
||
| 27 | { |
||
| 28 | return in_array(needle: $item, haystack: $this->items, strict: true); |
||
| 29 | } |
||
| 30 | |||
| 31 | public function pop(): mixed |
||
| 32 | { |
||
| 33 | if ($this->isEmpty()) { |
||
| 34 | return false; |
||
| 35 | } |
||
| 36 | |||
| 37 | return array_shift(array: $this->items); |
||
| 38 | } |
||
| 39 | |||
| 40 | public function push(mixed $item): void |
||
| 41 | { |
||
| 42 | if (null !== $item) { |
||
| 43 | $this->items[] = $item; |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | public function peek(): mixed |
||
| 48 | { |
||
| 49 | return current(array: $this->items); |
||
| 50 | } |
||
| 51 | |||
| 52 | public function isEmpty(): bool |
||
| 55 | } |
||
| 56 | |||
| 57 | public function count(): int |
||
| 58 | { |
||
| 59 | return count(value: $this->items); |
||
| 60 | } |
||
| 61 | } |
||
| 62 |