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