Passed
Push — master ( a2ae4c...9be3ef )
by Mike
02:07
created

Worker   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 30
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A runWorker() 0 8 4
1
<?php
2
3
4
namespace Xervice\RabbitMQ\Business\Model\Worker;
5
6
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Xervice\Core\Business\Model\Locator\Dynamic\Business\DynamicBusinessLocator;
9
use Xervice\RabbitMQ\Business\Model\Worker\Listener\ListenerCollection;
10
11
/**
12
 * @method \Xervice\RabbitMQ\Business\RabbitMQFacade getFacade()
13
 */
14
class Worker implements WorkerInterface
15
{
16
    use DynamicBusinessLocator;
17
18
    /**
19
     * @var \Xervice\RabbitMQ\Business\Model\Worker\Listener\ListenerCollection
20
     */
21
    private $listenerCollection;
22
23
    /**
24
     * Worker constructor.
25
     *
26
     * @param \Xervice\RabbitMQ\Business\Model\Worker\Listener\ListenerCollection $listenerCollection
27
     */
28 2
    public function __construct(ListenerCollection $listenerCollection)
29
    {
30 2
        $this->listenerCollection = $listenerCollection;
31 2
    }
32
33
    /**
34
     * @param \Symfony\Component\Console\Output\OutputInterface $output
35
     */
36 2
    public function runWorker(OutputInterface $output = null): void
37
    {
38 2
        foreach ($this->listenerCollection as $listener) {
39 2
            if ($output !== null && $output->isDebug()) {
40
                $output->writeln('Run listener for queue <info>' . $listener->getQueueName() . '</info>');
41
            }
42
43 2
            $this->getFacade()->consumeQueries($listener);
44
        }
45
    }
46
}