Passed
Push — master ( b520c6...4ddac5 )
by Mike
03:27
created

ExchangeProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 19
dl 0
loc 52
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A declare() 0 12 1
A delete() 0 4 1
1
<?php
2
3
4
namespace Xervice\RabbitMQ\Core;
5
6
7
use DataProvider\RabbitMqExchangeDataProvider;
8
use PhpAmqpLib\Channel\AMQPChannel;
9
10
class ExchangeProvider implements ExchangeProviderInterface
11
{
12
    const TYPE_DIRECT = 'direct';
13
    const TYPE_FANOUT = 'fanout';
14
    const TYPE_TOPIC = 'topic';
15
16
    /**
17
     * @var \PhpAmqpLib\Channel\AMQPChannel
18
     */
19
    private $channel;
20
21
    /**
22
     * Exchange constructor.
23
     *
24
     * @param \PhpAmqpLib\Channel\AMQPChannel $channel
25
     */
26
    public function __construct(AMQPChannel $channel)
27
    {
28
        $this->channel = $channel;
29
    }
30
31
    /**
32
     * @param string $name
33
     * @param string $type
34
     * @param bool $passive
35
     * @param bool $durable
36
     * @param bool $auto_delete
37
     * @param bool $internal
38
     * @param bool $nowait
39
     */
40
    public function declare(RabbitMqExchangeDataProvider $exchangeDataProvider): void
0 ignored issues
show
Coding Style introduced by
Possible parse error: non-abstract method defined as abstract
Loading history...
Coding Style introduced by
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
41
    {
42
        $this->channel->exchange_declare(
43
            $exchangeDataProvider->getName(),
44
            $exchangeDataProvider->getType(),
45
            $exchangeDataProvider->getPassive(),
46
            $exchangeDataProvider->getDurable(),
47
            $exchangeDataProvider->getAutoDelete(),
48
            $exchangeDataProvider->getInternal(),
49
            $exchangeDataProvider->getNoWait(),
50
            $exchangeDataProvider->getArgument(),
51
            $exchangeDataProvider->getTicket()
52
        );
53
    }
54
55
    /**
56
     * @param \DataProvider\RabbitMqExchangeDataProvider $exchangeDataProvider
57
     */
58
    public function delete(RabbitMqExchangeDataProvider $exchangeDataProvider): void
59
    {
60
        $this->channel->exchange_delete(
61
            $exchangeDataProvider->getName()
62
        );
63
    }
64
65
66
}