ConsumableParameters::__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\Consumer;
4
5
class ConsumableParameters implements Consumable
6
{
7
    /**
8
     * @var string
9
     */
10
    private $queueName;
11
12
    /**
13
     * @var string
14
     */
15
    private $consumerTag = '';
16
17
    private $callback;
18
19
    /**
20
     * @var bool
21
     */
22
    private $noLocal = false;
23
24
    /**
25
     * @var bool
26
     */
27
    private $noAck = false;
28
29
    /**
30
     * @var bool
31
     */
32
    private $exclusive = false;
33
34
    /**
35
     * @var bool
36
     */
37
    private $noWait = false;
38
39
    /**
40
     * @var int
41
     */
42
    private $ticket;
43
44
    /**
45
     * @var array
46
     */
47
    private $arguments = [];
48
49 5
    public function __construct(
50
        string $queueName,
51
        string $consumerTag = '',
52
        $callback = null,
53
        bool $noLocal = false,
54
        bool $noAck = false,
55
        bool $exclusive = false,
56
        bool $noWait = false,
57
        $ticket = null,
58
        array $arguments = []
59
    ) {
60 5
        $this->queueName = $queueName;
61 5
        $this->consumerTag = $consumerTag;
62 5
        $this->callback = $callback;
63 5
        $this->noLocal = $noLocal;
64 5
        $this->noAck = $noAck;
65 5
        $this->exclusive = $exclusive;
66 5
        $this->noWait = $noWait;
67 5
        $this->ticket = $ticket;
68 5
        $this->arguments = $arguments;
69 5
    }
70
71
    /**
72
     * @return string
73
     */
74 5
    public function getQueueName() : string
75
    {
76 5
        return $this->queueName;
77
    }
78
79 2
    public function getConsumerTag() : string
80
    {
81 2
        return $this->consumerTag;
82
    }
83
84 2
    public function getCallback()
85
    {
86 2
        return $this->callback;
87
    }
88
89 2
    public function setCallback($callback)
90
    {
91 2
        $this->callback = $callback;
92 2
    }
93
94 2
    public function isNoLocal() : bool
95
    {
96 2
        return $this->noLocal;
97
    }
98
99 3
    public function isNoAck() : bool
100
    {
101 3
        return $this->noAck;
102
    }
103
104 2
    public function isExclusive() : bool
105
    {
106 2
        return $this->exclusive;
107
    }
108
109 2
    public function isNoWait() : bool
110
    {
111 2
        return $this->noWait;
112
    }
113
114 3
    public function getTicket()
115
    {
116 3
        return $this->ticket;
117
    }
118
119 2
    public function getArguments() : array
120
    {
121 2
        return $this->arguments;
122
    }
123
}
124