Completed
Push — master ( 8acc04...458fbe )
by Laurent
02:26
created

CreateFlightBillCommand::__construct()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 35

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
nc 5
nop 8
dl 0
loc 35
rs 9.0488
c 0
b 0
f 0

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
 *
4
 */
5
6
/**
7
 * @author Laurent De Coninck <[email protected]>
8
 */
9
class CreateFlightBillCommand
10
{
11
    /**
12
     * @var int
13
     */
14
    private $flightId;
15
16
    /**
17
     * @var int
18
     */
19
    private $billingType;
20
21
    /**
22
     * @var int
23
     */
24
    private $billType;
25
26
    /**
27
     * @var int
28
     */
29
    private $billingCondition;
30
31
    /**
32
     * @var int
33
     */
34
    private $modelDocument;
35
36
    /**
37
     * @var string
38
     */
39
    private $publicNote;
40
41
    /**
42
     * @var string
43
     */
44
    private $privateNote;
45
46
    /**
47
     * @var int
48
     */
49
    private $bankAccount;
50
51
    /**
52
     * @param int    $flightId
53
     * @param int    $billingType
54
     * @param int    $billingCondition
55
     * @param int    $modelDocument
56
     * @param int    $billType
57
     * @param string $publicNote
58
     * @param string $privateNote
59
     * @param int    $bankAccount
60
     */
61
    public function __construct(
62
        $flightId,
63
        $billingType,
64
        $billingCondition,
65
        $modelDocument,
66
        $billType,
67
        $publicNote,
68
        $privateNote,
69
        $bankAccount
70
    ) {
71
        if (empty($flightId)) {
72
            throw new \InvalidArgumentException('Flight id is missing');
73
        }
74
75
        if (empty($billingType)) {
76
            throw new \InvalidArgumentException('Billing type is missing');
77
        }
78
79
        if (empty($billingCondition)) {
80
            throw new \InvalidArgumentException('Billing condition is missing');
81
        }
82
83
        if (empty($modelDocument)) {
84
            throw new \InvalidArgumentException('Model document is missing');
85
        }
86
87
        $this->flightId = $flightId;
88
        $this->billingType = $billingType;
89
        $this->billingCondition = $billingCondition;
90
        $this->modelDocument = $modelDocument;
91
        $this->billType = $billType;
92
        $this->publicNote = $publicNote;
93
        $this->privateNote = $privateNote;
94
        $this->bankAccount = $bankAccount;
95
    }
96
97
    /**
98
     * @return int
99
     */
100
    public function getFlightId()
101
    {
102
        return $this->flightId;
103
    }
104
105
    /**
106
     * @return int
107
     */
108
    public function getBillingType()
109
    {
110
        return $this->billingType;
111
    }
112
113
    /**
114
     * @return int
115
     */
116
    public function getBillingCondition()
117
    {
118
        return $this->billingCondition;
119
    }
120
121
    /**
122
     * @return int
123
     */
124
    public function getModelDocument()
125
    {
126
        return $this->modelDocument;
127
    }
128
129
    /**
130
     * @return int
131
     */
132
    public function getBillType()
133
    {
134
        return $this->billType;
135
    }
136
137
    /**
138
     * @return string
139
     */
140
    public function getPublicNote()
141
    {
142
        return $this->publicNote;
143
    }
144
145
    /**
146
     * @return string
147
     */
148
    public function getPrivateNote()
149
    {
150
        return $this->privateNote;
151
    }
152
153
    /**
154
     * @return int
155
     */
156
    public function getBankAccount()
157
    {
158
        return $this->bankAccount;
159
    }
160
161
162
}