| Total Complexity | 9 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class Manager |
||
| 13 | { |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var array|QueueInterface[]|DelayingInterface[]|CircularQueue[] |
||
| 17 | */ |
||
| 18 | private $queues = []; |
||
| 19 | |||
| 20 | public function __construct($queues = []) |
||
| 21 | { |
||
| 22 | if (!empty($queues)) { |
||
| 23 | foreach ($queues as $queue) { |
||
| 24 | $this->add($queue); |
||
| 25 | } |
||
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param QueueInterface|CircularQueue $queue |
||
| 31 | */ |
||
| 32 | public function add(QueueInterface $queue) |
||
| 33 | { |
||
| 34 | $this->queues[$queue->getName()] = $queue; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param string $queueName |
||
| 39 | * |
||
| 40 | * @throws \InvalidArgumentException |
||
| 41 | */ |
||
| 42 | public function remove(string $queueName) |
||
| 43 | { |
||
| 44 | if (isset($this->queues[$queueName])) { |
||
| 45 | unset($this->queues[$queueName]); |
||
| 46 | } else { |
||
| 47 | throw new InvalidArgumentException('Queue ' . $queueName . ' not registered'); |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | public function has(string $queueName): bool |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @param string $queueName |
||
| 58 | * |
||
| 59 | * @return CircularQueue|DelayingInterface|QueueInterface |
||
| 60 | * @throws \InvalidArgumentException |
||
| 61 | */ |
||
| 62 | public function queue(string $queueName) |
||
| 69 | } |
||
| 70 | } |
||
| 71 |