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