| Total Complexity | 9 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 9 | final class InMemoryQueue implements Queue |
||
| 10 | { |
||
| 11 | private $items = []; |
||
| 12 | |||
| 13 | 2 | public function add(Envelope $envelope): void |
|
| 14 | { |
||
| 15 | 2 | $this->offer($envelope); |
|
| 16 | 2 | } |
|
| 17 | |||
| 18 | 2 | public function offer(Envelope $envelope): bool |
|
| 19 | { |
||
| 20 | 2 | $this->items[] = $envelope; |
|
| 21 | |||
| 22 | 2 | return true; |
|
| 23 | } |
||
| 24 | |||
| 25 | 2 | public function remove(): Envelope |
|
| 34 | } |
||
| 35 | |||
| 36 | 2 | public function poll(): ?Envelope |
|
| 37 | { |
||
| 38 | 2 | $item = array_shift($this->items); |
|
| 39 | |||
| 40 | 2 | return $item ?: null; |
|
| 41 | } |
||
| 42 | |||
| 43 | 2 | public function element(): Envelope |
|
| 52 | } |
||
| 53 | |||
| 54 | 2 | public function peek(): ?Envelope |
|
| 55 | { |
||
| 61 |