Receipt::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 41

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 21
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 41
rs 9.264
c 0
b 0
f 0
cc 1
nc 1
nop 18
ccs 21
cts 21
cp 1
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 declare(strict_types = 1);
2
3
namespace SlevomatEET;
4
5
use DateTimeImmutable;
6
use Ramsey\Uuid\Uuid;
7
use Ramsey\Uuid\UuidInterface;
8
9
class Receipt
10
{
11
12
	/**
13
	 * XML uuid_zpravy
14
	 *
15
	 * @var UuidInterface
16
	 */
17
	private $uuid;
18
19
	/**
20
	 * XML prvni_zaslani
21
	 *
22
	 * @var bool
23
	 */
24
	private $firstSend = true;
25
26
	/**
27
	 * XML dic_poverujiciho
28
	 *
29
	 * @var string|null
30
	 */
31
	private $delegatedVatId;
32
33
	/**
34
	 * XML porad_cis
35
	 *
36
	 * @var string
37
	 */
38
	private $receiptNumber;
39
40
	/**
41
	 * XML dat_trzby
42
	 *
43
	 * @var DateTimeImmutable
44
	 */
45
	private $receiptTime;
46
47
	/**
48
	 * XML celk_trzba
49
	 *
50
	 * @var int
51
	 */
52
	private $totalPrice;
53
54
	/**
55
	 * XML zakl_nepodl_dph
56
	 *
57
	 * @var int|null
58
	 */
59
	private $priceZeroVat;
60
61
	/**
62
	 * XML zakl_dan1
63
	 *
64
	 * @var int|null
65
	 */
66
	private $priceStandardVat;
67
68
	/**
69
	 * XML dan1
70
	 *
71
	 * @var int|null
72
	 */
73
	private $vatStandard;
74
75
	/**
76
	 * XML zakl_dan2
77
	 *
78
	 * @var int|null
79
	 */
80
	private $priceFirstReducedVat;
81
82
	/**
83
	 * XML dan2
84
	 *
85
	 * @var int|null
86
	 */
87
	private $vatFirstReduced;
88
89
	/**
90
	 * XML zakl_dan3
91
	 *
92
	 * @var int|null
93
	 */
94
	private $priceSecondReducedVat;
95
96
	/**
97
	 * XML dan3
98
	 *
99
	 * @var int|null
100
	 */
101
	private $vatSecondReduced;
102
103
	/**
104
	 * XML cest_sluz
105
	 *
106
	 * @var int|null
107
	 */
108
	private $priceTravelService;
109
110
	/**
111
	 * XML pouzit_zboz1
112
	 *
113
	 * @var int|null
114
	 */
115
	private $priceUsedGoodsStandardVat;
116
117
	/**
118
	 * XML pouzit_zboz2
119
	 *
120
	 * @var int|null
121
	 */
122
	private $priceUsedGoodsFirstReducedVat;
123
124
	/**
125
	 * XML pouzit_zboz3
126
	 *
127
	 * @var int|null
128
	 */
129
	private $priceUsedGoodsSecondReducedVat;
130
131
	/**
132
	 * XML urceno_cerp_zuct
133
	 *
134
	 * @var int|null
135
	 */
136
	private $priceForSubsequentSettlement;
137
138
	/**
139
	 * XML cerp_zuct
140
	 *
141
	 * @var int|null
142
	 */
143
	private $priceUsedSubsequentSettlement;
144
145 4
	public function __construct(
146
		bool $firstSend,
147
		?string $delegatedVatId,
148
		string $receiptNumber,
149
		DateTimeImmutable $receiptTime,
150
		int $totalPrice = 0,
151
		?int $priceZeroVat = null,
152
		?int $priceStandardVat = null,
153
		?int $vatStandard = null,
154
		?int $priceFirstReducedVat = null,
155
		?int $vatFirstReduced = null,
156
		?int $priceSecondReducedVat = null,
157
		?int $vatSecondReduced = null,
158
		?int $priceTravelService = null,
159
		?int $priceUsedGoodsStandardVat = null,
160
		?int $priceUsedGoodsFirstReducedVat = null,
161
		?int $priceUsedGoodsSecondReducedVat = null,
162
		?int $priceSubsequentSettlement = null,
163
		?int $priceUsedSubsequentSettlement = null
164
	)
165
	{
166 4
		$this->uuid = Uuid::uuid4();
167 4
		$this->firstSend = $firstSend;
168 4
		$this->delegatedVatId = $delegatedVatId;
169 4
		$this->receiptNumber = $receiptNumber;
170 4
		$this->receiptTime = $receiptTime;
171 4
		$this->totalPrice = $totalPrice;
172 4
		$this->priceZeroVat = $priceZeroVat;
173 4
		$this->priceStandardVat = $priceStandardVat;
174 4
		$this->vatStandard = $vatStandard;
175 4
		$this->priceFirstReducedVat = $priceFirstReducedVat;
176 4
		$this->vatFirstReduced = $vatFirstReduced;
177 4
		$this->priceSecondReducedVat = $priceSecondReducedVat;
178 4
		$this->vatSecondReduced = $vatSecondReduced;
179 4
		$this->priceTravelService = $priceTravelService;
180 4
		$this->priceUsedGoodsStandardVat = $priceUsedGoodsStandardVat;
181 4
		$this->priceUsedGoodsFirstReducedVat = $priceUsedGoodsFirstReducedVat;
182 4
		$this->priceUsedGoodsSecondReducedVat = $priceUsedGoodsSecondReducedVat;
183 4
		$this->priceForSubsequentSettlement = $priceSubsequentSettlement;
184 4
		$this->priceUsedSubsequentSettlement = $priceUsedSubsequentSettlement;
185 4
	}
186
187 4
	public function getUuid(): UuidInterface
188
	{
189 4
		return $this->uuid;
190
	}
191
192 4
	public function isFirstSend(): bool
193
	{
194 4
		return $this->firstSend;
195
	}
196
197 4
	public function getDelegatedVatId(): ?string
198
	{
199 4
		return $this->delegatedVatId;
200
	}
201
202 4
	public function getReceiptNumber(): string
203
	{
204 4
		return $this->receiptNumber;
205
	}
206
207 4
	public function getReceiptTime(): DateTimeImmutable
208
	{
209 4
		return $this->receiptTime;
210
	}
211
212 4
	public function getTotalPrice(): int
213
	{
214 4
		return $this->totalPrice;
215
	}
216
217 4
	public function getPriceZeroVat(): ?int
218
	{
219 4
		return $this->priceZeroVat;
220
	}
221
222 4
	public function getPriceStandardVat(): ?int
223
	{
224 4
		return $this->priceStandardVat;
225
	}
226
227 4
	public function getVatStandard(): ?int
228
	{
229 4
		return $this->vatStandard;
230
	}
231
232 4
	public function getPriceFirstReducedVat(): ?int
233
	{
234 4
		return $this->priceFirstReducedVat;
235
	}
236
237 4
	public function getVatFirstReduced(): ?int
238
	{
239 4
		return $this->vatFirstReduced;
240
	}
241
242 4
	public function getPriceSecondReducedVat(): ?int
243
	{
244 4
		return $this->priceSecondReducedVat;
245
	}
246
247 4
	public function getVatSecondReduced(): ?int
248
	{
249 4
		return $this->vatSecondReduced;
250
	}
251
252 4
	public function getPriceTravelService(): ?int
253
	{
254 4
		return $this->priceTravelService;
255
	}
256
257 4
	public function getPriceUsedGoodsStandardVat(): ?int
258
	{
259 4
		return $this->priceUsedGoodsStandardVat;
260
	}
261
262 4
	public function getPriceUsedGoodsFirstReducedVat(): ?int
263
	{
264 4
		return $this->priceUsedGoodsFirstReducedVat;
265
	}
266
267 4
	public function getPriceUsedGoodsSecondReducedVat(): ?int
268
	{
269 4
		return $this->priceUsedGoodsSecondReducedVat;
270
	}
271
272 4
	public function getPriceForSubsequentSettlement(): ?int
273
	{
274 4
		return $this->priceForSubsequentSettlement;
275
	}
276
277 4
	public function getPriceUsedSubsequentSettlement(): ?int
278
	{
279 4
		return $this->priceUsedSubsequentSettlement;
280
	}
281
282
}
283