RabbitMqQueueCreator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 42
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A createIfNecessary() 0 7 2
1
<?php
2
namespace PSB\Core\Transport\RabbitMq;
3
4
5
use PSB\Core\Transport\QueueBindings;
6
use PSB\Core\Transport\QueueCreatorInterface;
7
8
class RabbitMqQueueCreator implements QueueCreatorInterface
9
{
10
    /**
11
     * @var BrokerModel
12
     */
13
    private $brokerModel;
14
15
    /**
16
     * @var RoutingTopology
17
     */
18
    private $routingTopology;
19
20
    /**
21
     * @var bool
22
     */
23
    private $useDurableMessages;
24
25
    /**
26
     * @param BrokerModel     $brokerModel
27
     * @param RoutingTopology $routingTopology
28
     * @param bool            $useDurableMessages
29
     */
30 3
    public function __construct(BrokerModel $brokerModel, RoutingTopology $routingTopology, $useDurableMessages)
31
    {
32 3
        $this->brokerModel = $brokerModel;
33 3
        $this->routingTopology = $routingTopology;
34 3
        $this->useDurableMessages = $useDurableMessages;
35 3
    }
36
37
    /**
38
     * Creates message queues for the defined queue bindings.
39
     *
40
     * @param QueueBindings $queueBindings
41
     */
42 2
    public function createIfNecessary(QueueBindings $queueBindings)
43
    {
44 2
        $addresses = array_merge($queueBindings->getReceivingAddresses(), $queueBindings->getSendingAddresses());
45 2
        foreach ($addresses as $address) {
46 1
            $this->routingTopology->setupForEndpointUse($this->brokerModel, $address);
47
        }
48 2
    }
49
}
50