Completed
Push — master ( 23e91d...042a18 )
by Cody
02:22
created

QueueConfig   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 86.36%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 1
dl 0
loc 58
ccs 19
cts 22
cp 0.8636
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getExchange() 0 4 1
A getAmqpTable() 0 12 3
A isDurable() 0 4 1
A isExclusive() 0 4 1
A isAutoDelete() 0 4 1
A isNoWait() 0 4 1
A getTicket() 0 4 1
1
<?php
2
3
namespace Ccovey\RabbitMQ\Config;
4
5
use PhpAmqpLib\Wire\AMQPTable;
6
7
class QueueConfig
8
{
9
    /**
10
     * @var array
11
     */
12
    private $configuration;
13
14 1
    public function __construct(array $configuration)
15
    {
16 1
        $this->configuration = $configuration;
17 1
    }
18
19 1
    public function getExchange() : string
20
    {
21 1
        return $this->configuration['exchange'] ?? '';
22
    }
23
24
    /**
25
     * @return null|AMQPTable
26
     */
27 1
    public function getAmqpTable()
28
    {
29 1
        $amqpTable = null;
30 1
        if (isset($this->configuration['amqp_table'])) {
31
            $amqpTable = new AMQPTable();
32
            foreach ($this->configuration['aqmp_table'] as $key => $tableParam) {
33
                $amqpTable->set($key, $tableParam);
34
            }
35
        }
36
37 1
        return $amqpTable;
38
    }
39
40 1
    public function isDurable() : bool
41
    {
42 1
        return $this->configuration['durable'] ?? true;
43
    }
44
45 1
    public function isExclusive() : bool
46
    {
47 1
        return $this->configuration['exclusive'] ?? false;
48
    }
49
50 1
    public function isAutoDelete() : bool
51
    {
52 1
        return $this->configuration['autoDelete'] ?? false;
53
    }
54
55 1
    public function isNoWait() : bool
56
    {
57 1
        return $this->configuration['noWait'] ?? false;
58
    }
59
60 1
    public function getTicket()
61
    {
62 1
        return $this->configuration['ticket'] ?? null;
63
    }
64
}
65