Queue::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 11
cts 11
cp 1
rs 9.3142
c 0
b 0
f 0
cc 1
eloc 19
nc 1
nop 9
crap 1

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace Ccovey\RabbitMQ;
4
5
use PhpAmqpLib\Wire\AMQPTable;
6
7
class Queue
8
{
9
    /**
10
     * @var string
11
     */
12
    private $queueName;
13
14
    /**
15
     * @var AMQPTable
16
     */
17
    private $arguments;
18
19
    /**
20
     * @var string
21
     */
22
    private $exchange;
23
24
    /**
25
     * @var bool
26
     */
27
    private $passive;
28
29
    /**
30
     * @var bool
31
     */
32
    private $durable;
33
34
    /**
35
     * @var bool
36
     */
37
    private $exclusive;
38
39
    /**
40
     * @var bool
41
     */
42
    private $autoDelete;
43
44
    /**
45
     * @var bool
46
     */
47
    private $noWait;
48
49
    private $ticket;
50
51 5
    public function __construct(
52
        string $queueName,
53
        string $exchange = '',
54
        AMQPTable $arguments = null,
55
        bool $passive = false,
56
        bool $durable = true,
57
        bool $exclusive = false,
58
        bool $autoDelete = false,
59
        bool $noWait = false,
60
        int $ticket = null
61
    ) {
62 5
        $this->queueName = $queueName;
63 5
        $this->exchange = $exchange;
64 5
        $this->arguments = $arguments;
65 5
        $this->passive = $passive;
66 5
        $this->durable = $durable;
67 5
        $this->exclusive = $exclusive;
68 5
        $this->autoDelete = $autoDelete;
69 5
        $this->noWait = $noWait;
70 5
        $this->ticket = $ticket;
71 5
    }
72
73 4
    public function getQueueName() : string
74
    {
75 4
        return $this->queueName;
76
    }
77
78
    /**
79
     * @return AMQPTable|null
80
     */
81 4
    public function getArguments()
82
    {
83 4
        return $this->arguments;
84
    }
85
86 2
    public function isPassive() : bool
87
    {
88 2
        return $this->passive;
89
    }
90
91 3
    public function isDurable() : bool
92
    {
93 3
        return $this->durable;
94
    }
95
96 3
    public function isExclusive() : bool
97
    {
98 3
        return $this->exclusive;
99
    }
100
101 3
    public function isAutoDelete() : bool
102
    {
103 3
        return $this->autoDelete;
104
    }
105
106 4
    public function isNoWait() : bool
107
    {
108 4
        return $this->noWait;
109
    }
110
111 4
    public function getTicket()
112
    {
113 4
        return $this->ticket;
114
    }
115
116 2
    public function getExchange() : string
117
    {
118 2
        return $this->exchange;
119
    }
120
}
121