Passed
Push — main ( 7189b9...23cbe4 )
by Vasil
03:17
created

ShipmentAddress   B

Complexity

Total Complexity 47

Size/Duplication

Total Lines 519
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 73
dl 0
loc 519
ccs 95
cts 95
cp 1
rs 8.64
c 0
b 0
f 0
wmc 47

47 Methods

Rating   Name   Duplication   Size   Complexity  
A getStreetId() 0 3 1
A setY() 0 3 1
A getX() 0 3 1
A setX() 0 3 1
A getApartmentNo() 0 3 1
A setPoiId() 0 3 1
A setComplexName() 0 3 1
A getStateId() 0 3 1
A getBlockNo() 0 3 1
A getComplexId() 0 3 1
A getY() 0 3 1
A setAddressNote() 0 3 1
A getSiteType() 0 3 1
A setAddressLine2() 0 3 1
A getFloorNo() 0 3 1
A __construct() 0 3 1
A setSiteId() 0 3 1
A getSiteId() 0 3 1
A setStreetName() 0 3 1
A getEntranceNo() 0 3 1
A setSiteName() 0 3 1
A setComplexId() 0 3 1
A getAddressLine2() 0 3 1
A getStreetNo() 0 3 1
A setPostCode() 0 3 1
A getStreetName() 0 3 1
A setBlockNo() 0 3 1
A getStreetType() 0 3 1
A getComplexType() 0 3 1
A setStateId() 0 5 1
A setAddressLine1() 0 3 1
A setStreetId() 0 3 1
A getCountryId() 0 3 1
A setComplexType() 0 3 1
A setStreetNo() 0 3 1
A getAddressNote() 0 3 1
A getAddressLine1() 0 3 1
A getSiteName() 0 3 1
A setEntranceNo() 0 3 1
A setCountryId() 0 3 1
A setApartmentNo() 0 3 1
A setStreetType() 0 3 1
A getPostCode() 0 3 1
A setSiteType() 0 3 1
A getComplexName() 0 3 1
A getPoiId() 0 3 1
A setFloorNo() 0 3 1

How to fix   Complexity   

Complex Class

Complex classes like ShipmentAddress 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 ShipmentAddress, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
declare(strict_types=1);
4
5
namespace VasilDakov\Speedy\Service\Shipment;
6
7
use JMS\Serializer\Annotation as Serializer;
8
use VasilDakov\Speedy\Traits\ToArray;
9
10
/**
11
 * Class ShipmentAddress
12
 *
13
 * @author Valentin Valkanov <[email protected]>
14
 * @author Vasil Dakov <[email protected]>
15
 * @copyright
16
 * @version
17
 * @Serializer\AccessType("public_method")
18
 */
19
class ShipmentAddress
20
{
21
    use ToArray;
22
23
    /**
24
     * @var int|null
25
     * @Serializer\Type("integer")
26
     */
27
    private ?int $countryId = null;
28
29
    /**
30
     * @var string|null
31
     * @Serializer\Type("string")
32
     */
33
    private ?string $stateId = null;
34
35
    /**
36
     * @var int
37
     * @Serializer\Type("integer")
38
     */
39
    private int $siteId;
40
41
    /**
42
     * @var string|null
43
     * @Serializer\Type("string")
44
     */
45
    private ?string $siteType = null;
46
47
    /**
48
     * @var string|null
49
     * @Serializer\Type("string")
50
     */
51
    private ?string $siteName = null;
52
53
    /**
54
     * @var string|null
55
     * @Serializer\Type("string")
56
     */
57
    private ?string $postCode = null;
58
59
    /**
60
     * @var int|null
61
     * @Serializer\Type("integer")
62
     */
63
    private ?int $streetId = null;
64
65
    /**
66
     * @var string|null
67
     * @Serializer\Type("string")
68
     */
69
    private ?string $streetType = null;
70
71
    /**
72
     * @var string|null
73
     * @Serializer\Type("string")
74
     */
75
    private ?string $streetName = null;
76
77
    /**
78
     * @var string|null
79
     * @Serializer\Type("string")
80
     */
81
    private ?string $streetNo = null;
82
83
    /**
84
     * @var int|null
85
     * @Serializer\Type("integer")
86
     */
87
    private ?int $complexId = null;
88
89
    /**
90
     * @var string|null
91
     * @Serializer\Type("string")
92
     */
93
    private ?string $complexType = null;
94
95
    /**
96
     * @var string|null
97
     * @Serializer\Type("string")
98
     */
99
    private ?string $complexName = null;
100
101
    /**
102
     * @var string|null
103
     * @Serializer\Type("string")
104
     */
105
    private ?string $blockNo = null;
106
107
    /**
108
     * @var string|null
109
     * @Serializer\Type("string")
110
     */
111
    private ?string $entranceNo = null;
112
113
    /**
114
     * @var string|null
115
     * @Serializer\Type("string")
116
     */
117
    private ?string $floorNo = null;
118
119
    /**
120
     * @var string|null
121
     * @Serializer\Type("string")
122
     */
123
    private ?string $apartmentNo = null;
124
125
    /**
126
     * @var int|null
127
     * @Serializer\Type("integer")
128
     */
129
    private ?int $poiId = null;
130
131
    /**
132
     * @var string|null
133
     * @Serializer\Type("string")
134
     */
135
    private ?string $addressNote = null;
136
137
    /**
138
     * @var string|null
139
     * @Serializer\Type("string")
140
     */
141
    private ?string $addressLine1 = null;
142
143
    /**
144
     * @var string|null
145
     * @Serializer\Type("string")
146
     */
147
    private ?string $addressLine2 = null;
148
149
    /**
150
     * @var float|null
151
     * @Serializer\Type("float")
152
     */
153
    private ?float $x = null;
154
155
    /**
156
     * @var float|null
157
     * @Serializer\Type("float")
158
     */
159
    private ?float $y = null;
160
161
    /**
162
     * @param int $siteId
163
     */
164 1
    public function __construct(int $siteId)
165
    {
166 1
        $this->siteId = $siteId;
167
    }
168
169
    /**
170
     * @return int
171
     */
172 1
    public function getCountryId(): int
173
    {
174 1
        return $this->countryId;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->countryId could return the type null which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
175
    }
176
177
    /**
178
     * @param int $countryId
179
     */
180 2
    public function setCountryId(int $countryId): void
181
    {
182 2
        $this->countryId = $countryId;
183
    }
184
185
    /**
186
     * @return string|null
187
     */
188 1
    public function getStateId(): ?string
189
    {
190 1
        return $this->stateId;
191
    }
192
193
    /**
194
     * @param string $stateId
195
     * @return self
196
     */
197 2
    public function setStateId(string $stateId): self
198
    {
199 2
        $this->stateId = $stateId;
200
201 2
        return $this;
202
    }
203
204
    /**
205
     * @return int|null
206
     */
207 1
    public function getSiteId(): ?int
208
    {
209 1
        return $this->siteId;
210
    }
211
212
    /**
213
     * @param int $siteId
214
     */
215 2
    public function setSiteId(int $siteId): void
216
    {
217 2
        $this->siteId = $siteId;
218
    }
219
220
    /**
221
     * @return string|null
222
     */
223 1
    public function getSiteType(): ?string
224
    {
225 1
        return $this->siteType;
226
    }
227
228
    /**
229
     * @param string $siteType
230
     */
231 2
    public function setSiteType(string $siteType): void
232
    {
233 2
        $this->siteType = $siteType;
234
    }
235
236
    /**
237
     * @return string|null
238
     */
239 2
    public function getSiteName(): ?string
240
    {
241 2
        return $this->siteName;
242
    }
243
244
    /**
245
     * @param string $siteName
246
     */
247 5
    public function setSiteName(string $siteName): void
248
    {
249 5
        $this->siteName = $siteName;
250
    }
251
252
    /**
253
     * @return string|null
254
     */
255 1
    public function getPostCode(): ?string
256
    {
257 1
        return $this->postCode;
258
    }
259
260
    /**
261
     * @param string $postCode
262
     */
263 2
    public function setPostCode(string $postCode): void
264
    {
265 2
        $this->postCode = $postCode;
266
    }
267
268
    /**
269
     * @return int|null
270
     */
271 1
    public function getStreetId(): ?int
272
    {
273 1
        return $this->streetId;
274
    }
275
276
    /**
277
     * @param int $streetId
278
     */
279 2
    public function setStreetId(int $streetId): void
280
    {
281 2
        $this->streetId = $streetId;
282
    }
283
284
    /**
285
     * @return string|null
286
     */
287 1
    public function getStreetType(): ?string
288
    {
289 1
        return $this->streetType;
290
    }
291
292
    /**
293
     * @param string $streetType
294
     */
295 5
    public function setStreetType(string $streetType): void
296
    {
297 5
        $this->streetType = $streetType;
298
    }
299
300
    /**
301
     * @return string|null
302
     */
303 2
    public function getStreetName(): ?string
304
    {
305 2
        return $this->streetName;
306
    }
307
308
    /**
309
     * @param string $streetName
310
     */
311 5
    public function setStreetName(string $streetName): void
312
    {
313 5
        $this->streetName = $streetName;
314
    }
315
316
    /**
317
     * @return string|null
318
     */
319 1
    public function getStreetNo(): ?string
320
    {
321 1
        return $this->streetNo;
322
    }
323
324
    /**
325
     * @param string $streetNo
326
     */
327 5
    public function setStreetNo(string $streetNo): void
328
    {
329 5
        $this->streetNo = $streetNo;
330
    }
331
332
    /**
333
     * @return int|null
334
     */
335 1
    public function getComplexId(): ?int
336
    {
337 1
        return $this->complexId;
338
    }
339
340
    /**
341
     * @param ?int $complexId
342
     */
343 2
    public function setComplexId(?int $complexId): void
344
    {
345 2
        $this->complexId = $complexId;
346
    }
347
348
    /**
349
     * @return string|null
350
     */
351 1
    public function getComplexType(): ?string
352
    {
353 1
        return $this->complexType;
354
    }
355
356
    /**
357
     * @param ?string $complexType
358
     */
359 2
    public function setComplexType(?string $complexType): void
360
    {
361 2
        $this->complexType = $complexType;
362
    }
363
364
    /**
365
     * @return string|null
366
     */
367 1
    public function getComplexName(): ?string
368
    {
369 1
        return $this->complexName;
370
    }
371
372
    /**
373
     * @param string $complexName
374
     */
375 2
    public function setComplexName(string $complexName): void
376
    {
377 2
        $this->complexName = $complexName;
378
    }
379
380
    /**
381
     * @return string|null
382
     */
383 1
    public function getBlockNo(): ?string
384
    {
385 1
        return $this->blockNo;
386
    }
387
388
    /**
389
     * @param string $blockNo
390
     */
391 2
    public function setBlockNo(string $blockNo): void
392
    {
393 2
        $this->blockNo = $blockNo;
394
    }
395
396
    /**
397
     * @return string|null
398
     */
399 1
    public function getEntranceNo(): ?string
400
    {
401 1
        return $this->entranceNo;
402
    }
403
404
    /**
405
     * @param string $entranceNo
406
     */
407 2
    public function setEntranceNo(string $entranceNo): void
408
    {
409 2
        $this->entranceNo = $entranceNo;
410
    }
411
412
    /**
413
     * @return string|null
414
     */
415 1
    public function getFloorNo(): ?string
416
    {
417 1
        return $this->floorNo;
418
    }
419
420
    /**
421
     * @param string $floorNo
422
     */
423 2
    public function setFloorNo(string $floorNo): void
424
    {
425 2
        $this->floorNo = $floorNo;
426
    }
427
428
    /**
429
     * @return string|null
430
     */
431 1
    public function getApartmentNo(): ?string
432
    {
433 1
        return $this->apartmentNo;
434
    }
435
436
    /**
437
     * @param string $apartmentNo
438
     */
439 2
    public function setApartmentNo(string $apartmentNo): void
440
    {
441 2
        $this->apartmentNo = $apartmentNo;
442
    }
443
444
    /**
445
     * @return int|null
446
     */
447 1
    public function getPoiId(): ?int
448
    {
449 1
        return $this->poiId;
450
    }
451
452
    /**
453
     * @param ?int $poiId
454
     */
455 2
    public function setPoiId(?int $poiId): void
456
    {
457 2
        $this->poiId = $poiId;
458
    }
459
460
    /**
461
     * @return string|null
462
     */
463 1
    public function getAddressNote(): ?string
464
    {
465 1
        return $this->addressNote;
466
    }
467
468
    /**
469
     * @param string $addressNote
470
     */
471 2
    public function setAddressNote(string $addressNote): void
472
    {
473 2
        $this->addressNote = $addressNote;
474
    }
475
476
    /**
477
     * @return string|null
478
     */
479 1
    public function getAddressLine1(): ?string
480
    {
481 1
        return $this->addressLine1;
482
    }
483
484
    /**
485
     * @param string $addressLine1
486
     */
487 2
    public function setAddressLine1(string $addressLine1): void
488
    {
489 2
        $this->addressLine1 = $addressLine1;
490
    }
491
492
    /**
493
     * @return string|null
494
     */
495 1
    public function getAddressLine2(): ?string
496
    {
497 1
        return $this->addressLine2;
498
    }
499
500
    /**
501
     * @param string $addressLine2
502
     */
503 2
    public function setAddressLine2(string $addressLine2): void
504
    {
505 2
        $this->addressLine2 = $addressLine2;
506
    }
507
508
    /**
509
     * @return float|null
510
     */
511 1
    public function getX(): ?float
512
    {
513 1
        return $this->x;
514
    }
515
516
    /**
517
     * @param float $x
518
     */
519 2
    public function setX(float $x): void
520
    {
521 2
        $this->x = $x;
522
    }
523
524
    /**
525
     * @return float|null
526
     */
527 1
    public function getY(): ?float
528
    {
529 1
        return $this->y;
530
    }
531
532
    /**
533
     * @param float $y
534
     */
535 2
    public function setY(float $y): void
536
    {
537 2
        $this->y = $y;
538
    }
539
}
540