| Total Complexity | 5 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 9 | final class InMemoryQueue implements Queue |
||
| 10 | { |
||
| 11 | use HasDefaultRemoveAndElement; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @var Envelope[] |
||
| 15 | */ |
||
| 16 | private $items = []; |
||
| 17 | |||
| 18 | 2 | public function add(Envelope $envelope): bool |
|
| 19 | { |
||
| 20 | 2 | return $this->offer($envelope); |
|
| 21 | } |
||
| 22 | |||
| 23 | 2 | public function offer(Envelope $envelope): bool |
|
| 28 | } |
||
| 29 | |||
| 30 | 2 | public function poll(): ?Envelope |
|
| 31 | { |
||
| 32 | 2 | $item = array_shift($this->items); |
|
| 33 | |||
| 34 | 2 | return $item ?: null; |
|
| 35 | } |
||
| 36 | |||
| 37 | 2 | public function peek(): ?Envelope |
|
| 42 | } |
||
| 43 | } |
||
| 44 |