Passed
Push — master ( edeb69...38b3d3 )
by Tomáš
11:24
created

DeliveryData   A

Complexity

Total Complexity 42

Size/Duplication

Total Lines 430
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 43
dl 0
loc 430
ccs 125
cts 125
cp 1
rs 9.0399
c 1
b 0
f 0
wmc 42

42 Methods

Rating   Name   Duplication   Size   Complexity  
A setDelInsurance() 0 3 1
A setPIN() 0 3 1
A setDelAccountNumber() 0 3 1
A setFullAgeMinimum() 0 3 1
A setSatDelivery() 0 3 1
A setComfortExclusiveService() 0 3 1
A setPassword() 0 3 1
A setPersDeliveryDepartment() 0 3 1
A setNoteDriver() 0 3 1
A setDelExworks() 0 3 1
A setNoteCustomer() 0 3 1
A setPersDeliveryBuilding() 0 3 1
A setRequireFullAge() 0 3 1
A setDelZip() 0 3 1
A setPersDeliveryFloor() 0 3 1
A setDelEvening() 0 3 1
A setFullAgeData() 0 3 1
A setRecEnterance() 0 3 1
A setDeliveryDate() 0 3 1
A setFloor() 0 3 1
A setDeliveryCostsEUR() 0 3 1
A setOpenBeforePayment() 0 3 1
A setRecHouseNumber() 0 3 1
A setDeclarationOtherCharges() 0 3 1
A setDeclarationTransportCharges() 0 3 1
A setPickupDate() 0 3 1
A setDeclarationChargesDiscount() 0 3 1
A setComfortServicePlus() 0 3 1
A setDelCountryCode() 0 3 1
A setFlatNumber() 0 3 1
A setIsAlcohol() 0 3 1
A setSwapOption() 0 3 1
A setDeliveryCosts() 0 3 1
A setComfortService() 0 3 1
A setSwap() 0 3 1
A setPickupTimeTo() 0 3 1
A setRecBlock() 0 3 1
A setDeclarationInsuranceCharges() 0 3 1
A setDeclarationComments() 0 3 1
A setPickupTimeFrom() 0 3 1
A setTestBeforePayment() 0 3 1
A setNote() 0 3 1

How to fix   Complexity   

Complex Class

Complex classes like DeliveryData often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use DeliveryData, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Inspirum\Balikobot\Model\Values\Package;
6
7
use DateTime;
8
use Inspirum\Balikobot\Definitions\Option;
9
10
trait DeliveryData
11
{
12
    /**
13
     * Set the item at a given offset
14
     *
15
     * @param string $key
16
     * @param mixed  $value
17
     *
18
     * @return void
19
     */
20
    abstract public function offsetSet(string $key, mixed $value): void;
21
22
    /**
23
     * @param string $noteDriver
24
     *
25
     * @return void
26
     */
27 1
    public function setNoteDriver(string $noteDriver): void
28
    {
29 1
        $this->offsetSet(Option::NOTE_DRIVER, $noteDriver);
30 1
    }
31
32
    /**
33
     * @param string $noteCustomer
34
     *
35
     * @return void
36
     */
37 1
    public function setNoteCustomer(string $noteCustomer): void
38
    {
39 1
        $this->offsetSet(Option::NOTE_CUSTOMER, $noteCustomer);
40 1
    }
41
42
    /**
43
     * @param bool $comfortExclusiveService
44
     *
45
     * @return void
46
     */
47 1
    public function setComfortExclusiveService(bool $comfortExclusiveService = true): void
48
    {
49 1
        $this->offsetSet(Option::COMFORT_EXCLUSIVE_SERVICE, (int) $comfortExclusiveService);
50 1
    }
51
52
    /**
53
     * @param bool $persDeliveryFloor
54
     *
55
     * @return void
56
     */
57 1
    public function setPersDeliveryFloor(bool $persDeliveryFloor = true): void
58
    {
59 1
        $this->offsetSet(Option::PERS_DELIVERY_FLOOR, (int) $persDeliveryFloor);
60 1
    }
61
62
    /**
63
     * @param bool $persDeliveryBuilding
64
     *
65
     * @return void
66
     */
67 1
    public function setPersDeliveryBuilding(bool $persDeliveryBuilding = true): void
68
    {
69 1
        $this->offsetSet(Option::PERS_DELIVERY_BUILDING, (int) $persDeliveryBuilding);
70 1
    }
71
72
    /**
73
     * @param bool $persDeliveryDepartment
74
     *
75
     * @return void
76
     */
77 1
    public function setPersDeliveryDepartment(bool $persDeliveryDepartment = true): void
78
    {
79 1
        $this->offsetSet(Option::PERS_DELIVERY_DEPARTMENT, (int) $persDeliveryDepartment);
80 1
    }
81
82
    /**
83
     * @param string $pin
84
     *
85
     * @return void
86
     */
87 1
    public function setPIN(string $pin): void
88
    {
89 1
        $this->offsetSet(Option::PIN, $pin);
90 1
    }
91
92
    /**
93
     * @param bool $satDelivery
94
     *
95
     * @return void
96
     */
97 1
    public function setSatDelivery(bool $satDelivery = true): void
98
    {
99 1
        $this->offsetSet(Option::SAT_DELIVERY, (int) $satDelivery);
100 1
    }
101
102
    /**
103
     * @param bool $requireFullAge
104
     *
105
     * @return void
106
     */
107 1
    public function setRequireFullAge(bool $requireFullAge = true): void
108
    {
109 1
        $this->offsetSet(Option::REQUIRE_FULL_AGE, (int) $requireFullAge);
110 1
    }
111
112
    /**
113
     * @param string $fullAgeMinimum
114
     *
115
     * @return void
116
     */
117 1
    public function setFullAgeMinimum(string $fullAgeMinimum): void
118
    {
119 1
        $this->offsetSet(Option::FULL_AGE_MINIMUM, $fullAgeMinimum);
120 1
    }
121
122
    /**
123
     * @param string $fullAgeData
124
     *
125
     * @return void
126
     */
127 1
    public function setFullAgeData(string $fullAgeData): void
128
    {
129 1
        $this->offsetSet(Option::FULL_AGE_DATA, $fullAgeData);
130 1
    }
131
132
    /**
133
     * @param string $password
134
     *
135
     * @return void
136
     */
137 1
    public function setPassword(string $password): void
138
    {
139 1
        $this->offsetSet(Option::PASSWORD, $password);
140 1
    }
141
142
    /**
143
     * @param bool $delInsurance
144
     *
145
     * @return void
146
     */
147 1
    public function setDelInsurance(bool $delInsurance = true): void
148
    {
149 1
        $this->offsetSet(Option::DEL_INSURANCE, (int) $delInsurance);
150 1
    }
151
152
    /**
153
     * @param bool $delEvening
154
     *
155
     * @return void
156
     */
157 1
    public function setDelEvening(bool $delEvening = true): void
158
    {
159 1
        $this->offsetSet(Option::DEL_EVENING, (int) $delEvening);
160 1
    }
161
162
    /**
163
     * @param bool $delExworks
164
     *
165
     * @return void
166
     */
167 1
    public function setDelExworks(bool $delExworks = true): void
168
    {
169 1
        $this->offsetSet(Option::DEL_EXWORKS, (int) $delExworks);
170 1
    }
171
172
    /**
173
     * @param string $delAccountNumber
174
     *
175
     * @return void
176
     */
177 1
    public function setDelAccountNumber(string $delAccountNumber): void
178
    {
179 1
        $this->offsetSet(Option::DEL_EXWORKS_ACCOUNT_NUMBER, $delAccountNumber);
180 1
    }
181
182
    /**
183
     * @param string $delZip
184
     *
185
     * @return void
186
     */
187 1
    public function setDelZip(string $delZip): void
188
    {
189 1
        $this->offsetSet(Option::DEL_EXWORKS_ZIP, $delZip);
190 1
    }
191
192
    /**
193
     * @param string $countryCode
194
     *
195
     * @return void
196
     */
197 1
    public function setDelCountryCode(string $countryCode): void
198
    {
199 1
        $this->offsetSet(Option::DEL_EXWORKS_COUNTRY_CODE, $countryCode);
200 1
    }
201
202
    /**
203
     * @param bool $comfort
204
     *
205
     * @return void
206
     */
207 1
    public function setComfortService(bool $comfort = true): void
208
    {
209 1
        $this->offsetSet(Option::COMFORT_SERVICE, (int) $comfort);
210 1
    }
211
212
    /**
213
     * @param bool $comfort
214
     *
215
     * @return void
216
     */
217 1
    public function setComfortServicePlus(bool $comfort = true): void
218
    {
219 1
        $this->offsetSet(Option::COMFORT_SERVICE_PLUS, (int) $comfort);
220 1
    }
221
222
    /**
223
     * @param \DateTime $deliveryDate
224
     *
225
     * @return void
226
     */
227 1
    public function setDeliveryDate(DateTime $deliveryDate): void
228
    {
229 1
        $this->offsetSet(Option::DELIVERY_DATE, $deliveryDate->format('Y-m-d'));
230 1
    }
231
232
    /**
233
     * @param bool $swap
234
     *
235
     * @return void
236
     */
237 1
    public function setSwap(bool $swap): void
238
    {
239 1
        $this->offsetSet(Option::SWAP, (int) $swap);
240 1
    }
241
242
    /**
243
     * @param string $swapOption
244
     *
245
     * @return void
246
     */
247 1
    public function setSwapOption(string $swapOption): void
248
    {
249 1
        $this->offsetSet(Option::SWAP_OPTION, $swapOption);
250 1
    }
251
252
    /**
253
     * @param bool $openBeforePayment
254
     *
255
     * @return void
256
     */
257 1
    public function setOpenBeforePayment(bool $openBeforePayment = true): void
258
    {
259 1
        $this->offsetSet(Option::OPEN_BEFORE_PAYMENT, (int) $openBeforePayment);
260 1
    }
261
262
    /**
263
     * @param bool $testBeforePayment
264
     *
265
     * @return void
266
     */
267 1
    public function setTestBeforePayment(bool $testBeforePayment = true): void
268
    {
269 1
        $this->offsetSet(Option::TEST_BEFORE_PAYMENT, (int) $testBeforePayment);
270 1
    }
271
272
    /**
273
     * @param string $note
274
     *
275
     * @return void
276
     */
277 1
    public function setNote(string $note): void
278
    {
279 1
        $this->offsetSet(Option::NOTE, $note);
280 1
    }
281
282
    /**
283
     * @param string $recHouseNumber
284
     *
285
     * @return void
286
     */
287 1
    public function setRecHouseNumber(string $recHouseNumber): void
288
    {
289 1
        $this->offsetSet(Option::REC_HOUSE_NUMBER, $recHouseNumber);
290 1
    }
291
292
    /**
293
     * @param string $recBlock
294
     *
295
     * @return void
296
     */
297 1
    public function setRecBlock(string $recBlock): void
298
    {
299 1
        $this->offsetSet(Option::REC_BLOCK, $recBlock);
300 1
    }
301
302
    /**
303
     * @param string $recEnteracne
304
     *
305
     * @return void
306
     */
307 1
    public function setRecEnterance(string $recEnteracne): void
308
    {
309 1
        $this->offsetSet(Option::REC_ENTERANCE, $recEnteracne);
310 1
    }
311
312
    /**
313
     * @param string $recFloor
314
     *
315
     * @return void
316
     */
317 1
    public function setFloor(string $recFloor): void
318
    {
319 1
        $this->offsetSet(Option::REC_FLOOR, $recFloor);
320 1
    }
321
322
    /**
323
     * @param string $recFlatNumber
324
     *
325
     * @return void
326
     */
327 1
    public function setFlatNumber(string $recFlatNumber): void
328
    {
329 1
        $this->offsetSet(Option::REC_FLAT_NUMBER, $recFlatNumber);
330 1
    }
331
332
    /**
333
     * @param float $deliveryCosts
334
     *
335
     * @return void
336
     */
337 1
    public function setDeliveryCosts(float $deliveryCosts): void
338
    {
339 1
        $this->offsetSet(Option::DELIVERY_COSTS, $deliveryCosts);
340 1
    }
341
342
    /**
343
     * @param float $deliveryCosts
344
     *
345
     * @return void
346
     */
347 1
    public function setDeliveryCostsEUR(float $deliveryCosts): void
348
    {
349 1
        $this->offsetSet(Option::DELIVERY_COSTS_EUR, $deliveryCosts);
350 1
    }
351
352
    /**
353
     * @param \DateTime $pickupDate
354
     *
355
     * @return void
356
     */
357 1
    public function setPickupDate(DateTime $pickupDate): void
358
    {
359 1
        $this->offsetSet(Option::PICKUP_DATE, $pickupDate->format('Y-m-d'));
360 1
    }
361
362
    /**
363
     * @param \DateTime $pickupTimeFrom
364
     *
365
     * @return void
366
     */
367 1
    public function setPickupTimeFrom(DateTime $pickupTimeFrom): void
368
    {
369 1
        $this->offsetSet(Option::PICKUP_TIME_FROM, $pickupTimeFrom->format('H:i'));
370 1
    }
371
372
    /**
373
     * @param \DateTime $pickupTimeTo
374
     *
375
     * @return void
376
     */
377 1
    public function setPickupTimeTo(DateTime $pickupTimeTo): void
378
    {
379 1
        $this->offsetSet(Option::PICKUP_TIME_TO, $pickupTimeTo->format('H:i'));
380 1
    }
381
382
    /**
383
     * @param string $value
384
     *
385
     * @return void
386
     */
387 1
    public function setDeclarationComments(string $value): void
388
    {
389 1
        $this->offsetSet(Option::DECLARATION_COMMENTS, $value);
390 1
    }
391
392
    /**
393
     * @param float $value
394
     *
395
     * @return void
396
     */
397 1
    public function setDeclarationChargesDiscount(float $value): void
398
    {
399 1
        $this->offsetSet(Option::DECLARATION_CHARGES_DISCOUNT, $value);
400 1
    }
401
402
    /**
403
     * @param float $value
404
     *
405
     * @return void
406
     */
407 1
    public function setDeclarationInsuranceCharges(float $value): void
408
    {
409 1
        $this->offsetSet(Option::DECLARATION_INSURANCE_CHARGES, $value);
410 1
    }
411
412
    /**
413
     * @param float $value
414
     *
415
     * @return void
416
     */
417 1
    public function setDeclarationOtherCharges(float $value): void
418
    {
419 1
        $this->offsetSet(Option::DECLARATION_OTHER_CHARGES, $value);
420 1
    }
421
422
    /**
423
     * @param float $value
424
     *
425
     * @return void
426
     */
427 1
    public function setDeclarationTransportCharges(float $value): void
428
    {
429 1
        $this->offsetSet(Option::DECLARATION_TRANSPORT_CHARGES, $value);
430 1
    }
431
432
    /**
433
     * @param bool $value
434
     *
435
     * @return void
436
     */
437 1
    public function setIsAlcohol(bool $value): void
438
    {
439 1
        $this->offsetSet(Option::IS_ALCOHOL, $value);
440 1
    }
441
}
442