ShippingOption   B
last analyzed

Complexity

Total Complexity 43

Size/Duplication

Total Lines 530
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 530
rs 8.3157
c 0
b 0
f 0
wmc 43

43 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 3 1
A setType() 0 5 1
A setDeliverySchemaLineId() 0 5 1
A setNeedsAdditionalShipperNotification() 0 5 1
A setContract() 0 5 1
A getPriceDiscount() 0 3 1
A getDescription() 0 3 1
A getDistributor() 0 3 1
A setOption() 0 5 1
A getPrice() 0 3 1
A isInsurance() 0 3 1
A isCod() 0 3 1
A setNeedsServicePointAccountNumber() 0 5 1
A setPriceDiscount() 0 5 1
A setAllowsAdditionalShipperNotification() 0 5 1
A setShipperNotification() 0 5 1
A isAllowsAdditionalShipperNotification() 0 3 1
A getDeliveryWindowEnd() 0 3 1
A setPrice() 0 5 1
A getShippingOption() 0 3 1
A setDescription() 0 5 1
A getOption() 0 3 1
A setDistributor() 0 5 1
A getDeliveryDayOfWeekRange() 0 3 1
A setInsurance() 0 5 1
A isDatePreference() 0 3 1
A setShippingOption() 0 5 1
A setServicePoints() 0 5 1
A getContract() 0 3 1
A __construct() 0 6 1
A setDeliveryWindowEnd() 0 5 1
A setCod() 0 5 1
A setDeliveryWindowStart() 0 5 1
A getServicePoints() 0 3 1
A getDeliveryWindowStart() 0 3 1
A isNeedsAdditionalShipperNotification() 0 3 1
A getPartOfDay() 0 3 1
A setPartOfDay() 0 5 1
A setDatePreference() 0 5 1
A isShipperNotification() 0 3 1
A getDeliverySchemaLineId() 0 3 1
A isNeedsServicePointAccountNumber() 0 3 1
A setDeliveryDayOfWeekRange() 0 5 1

How to fix   Complexity   

Complex Class

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

1
<?php
2
3
/*
4
 * This file is part of PHP CS Fixer.
5
 *
6
 * (c) Fabien Potencier <[email protected]>
7
 *     Dariusz Rumiński <[email protected]>
8
 *
9
 * This source file is subject to the MIT license that is bundled
10
 * with this source code in the file LICENSE.
11
 */
12
13
namespace Etrias\PaazlConnector\SoapTypes;
14
15
class ShippingOption extends ShippingOptionDetailsType
16
{
17
    /**
18
     * @var string
19
     */
20
    protected $type = null;
21
22
    /**
23
     * @var string
24
     */
25
    protected $deliverySchemaLineId = null;
26
27
    /**
28
     * @var string
29
     */
30
    protected $partOfDay = null;
31
32
    /**
33
     * @var float
34
     */
35
    protected $price;
36
37
    /**
38
     * @var float
39
     */
40
    protected $priceDiscount;
41
42
    /**
43
     * @var string
44
     */
45
    protected $deliveryDayOfWeekRange;
46
47
    /**
48
     * @var string
49
     */
50
    protected $deliveryWindowStart;
51
52
    /**
53
     * @var string
54
     */
55
    protected $deliveryWindowEnd;
56
57
    /**
58
     * @var bool
59
     */
60
    protected $datePreference;
61
62
    /**
63
     * @var bool
64
     */
65
    protected $cod;
66
67
    /**
68
     * @var bool
69
     */
70
    protected $insurance;
71
72
    /** @var bool */
73
    protected $needsServicePointAccountNumber;
74
75
    /**
76
     * @var bool
77
     */
78
    protected $shipperNotification;
79
80
    /**
81
     * @var bool
82
     */
83
    protected $needsAdditionalShipperNotification;
84
85
    /**
86
     * @var bool
87
     */
88
    protected $allowsAdditionalShipperNotification;
89
90
    /**
91
     * @var string
92
     */
93
    protected $distributor = null;
94
95
    /**
96
     * @var string
97
     */
98
    protected $shippingOption = null;
99
100
    /**
101
     * @var servicePointsType
102
     */
103
    protected $servicePoints = null;
104
105
    /**
106
     * Constructor.
107
     *
108
     * @param string $distributor
109
     * @param string $shippingOption
110
     *
111
     * @var servicePointsType $servicePoint
112
     *
113
     * @param string $contract
114
     * @param $option
115
     * @param $description
116
     * @param mixed $servicePoint
117
     * @param mixed $servicePoints
118
     */
119
    public function __construct($distributor, $shippingOption, $servicePoints, $contract, $option, $description)
120
    {
121
        parent::__construct($distributor, $contract, $option, $description);
122
        $this->distributor = $distributor;
123
        $this->shippingOption = $shippingOption;
124
        $this->servicePoints = $servicePoints;
0 ignored issues
show
Documentation Bug introduced by
$servicePoints is of type mixed, but the property $servicePoints was declared to be of type Etrias\PaazlConnector\SoapTypes\servicePointsType. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
125
    }
126
127
    /**
128
     * @return string
129
     */
130
    public function getDistributor()
131
    {
132
        return $this->distributor;
133
    }
134
135
    /**
136
     * @param string $distributor
137
     *
138
     * @return $this
139
     */
140
    public function setDistributor($distributor)
141
    {
142
        $this->distributor = $distributor;
143
144
        return $this;
145
    }
146
147
    /**
148
     * @return string
149
     */
150
    public function getShippingOption()
151
    {
152
        return $this->shippingOption;
153
    }
154
155
    /**
156
     * @param string $shippingOption
157
     *
158
     * @return $this
159
     */
160
    public function setShippingOption($shippingOption)
161
    {
162
        $this->shippingOption = $shippingOption;
163
164
        return $this;
165
    }
166
167
    /**
168
     * @return servicePointsType
169
     */
170
    public function getServicePoints()
171
    {
172
        return $this->servicePoints;
173
    }
174
175
    /**
176
     * @param servicePointsType $servicePoints
177
     *
178
     * @return $this
179
     */
180
    public function setServicePoints($servicePoints)
181
    {
182
        $this->servicePoints = $servicePoints;
183
184
        return $this;
185
    }
186
187
    /**
188
     * @return string
189
     */
190
    public function getType()
191
    {
192
        return $this->type;
193
    }
194
195
    /**
196
     * @param string $type
197
     *
198
     * @return ShippingOption
199
     */
200
    public function setType($type)
201
    {
202
        $this->type = $type;
203
204
        return $this;
205
    }
206
207
    /**
208
     * @return string
209
     */
210
    public function getDeliverySchemaLineId()
211
    {
212
        return $this->deliverySchemaLineId;
213
    }
214
215
    /**
216
     * @param string $deliverySchemaLineId
217
     *
218
     * @return ShippingOption
219
     */
220
    public function setDeliverySchemaLineId($deliverySchemaLineId)
221
    {
222
        $this->deliverySchemaLineId = $deliverySchemaLineId;
223
224
        return $this;
225
    }
226
227
    /**
228
     * @return string
229
     */
230
    public function getPartOfDay()
231
    {
232
        return $this->partOfDay;
233
    }
234
235
    /**
236
     * @param string $partOfDay
237
     *
238
     * @return ShippingOption
239
     */
240
    public function setPartOfDay($partOfDay)
241
    {
242
        $this->partOfDay = $partOfDay;
243
244
        return $this;
245
    }
246
247
    /**
248
     * @return float
249
     */
250
    public function getPrice()
251
    {
252
        return $this->price;
253
    }
254
255
    /**
256
     * @param float $price
257
     *
258
     * @return ShippingOption
259
     */
260
    public function setPrice($price)
261
    {
262
        $this->price = $price;
263
264
        return $this;
265
    }
266
267
    /**
268
     * @return float
269
     */
270
    public function getPriceDiscount()
271
    {
272
        return $this->priceDiscount;
273
    }
274
275
    /**
276
     * @param float $priceDiscount
277
     *
278
     * @return ShippingOption
279
     */
280
    public function setPriceDiscount($priceDiscount)
281
    {
282
        $this->priceDiscount = $priceDiscount;
283
284
        return $this;
285
    }
286
287
    /**
288
     * @return string
289
     */
290
    public function getDeliveryDayOfWeekRange()
291
    {
292
        return $this->deliveryDayOfWeekRange;
293
    }
294
295
    /**
296
     * @param string $deliveryDayOfWeekRange
297
     *
298
     * @return ShippingOption
299
     */
300
    public function setDeliveryDayOfWeekRange($deliveryDayOfWeekRange)
301
    {
302
        $this->deliveryDayOfWeekRange = $deliveryDayOfWeekRange;
303
304
        return $this;
305
    }
306
307
    /**
308
     * @return string
309
     */
310
    public function getDeliveryWindowStart()
311
    {
312
        return $this->deliveryWindowStart;
313
    }
314
315
    /**
316
     * @param string $deliveryWindowStart
317
     *
318
     * @return ShippingOption
319
     */
320
    public function setDeliveryWindowStart($deliveryWindowStart)
321
    {
322
        $this->deliveryWindowStart = $deliveryWindowStart;
323
324
        return $this;
325
    }
326
327
    /**
328
     * @return string
329
     */
330
    public function getDeliveryWindowEnd()
331
    {
332
        return $this->deliveryWindowEnd;
333
    }
334
335
    /**
336
     * @param string $deliveryWindowEnd
337
     *
338
     * @return ShippingOption
339
     */
340
    public function setDeliveryWindowEnd($deliveryWindowEnd)
341
    {
342
        $this->deliveryWindowEnd = $deliveryWindowEnd;
343
344
        return $this;
345
    }
346
347
    /**
348
     * @return bool
349
     */
350
    public function isDatePreference()
351
    {
352
        return $this->datePreference;
353
    }
354
355
    /**
356
     * @param bool $datePreference
357
     *
358
     * @return ShippingOption
359
     */
360
    public function setDatePreference($datePreference)
361
    {
362
        $this->datePreference = $datePreference;
363
364
        return $this;
365
    }
366
367
    /**
368
     * @return bool
369
     */
370
    public function isCod()
371
    {
372
        return $this->cod;
373
    }
374
375
    /**
376
     * @param bool $cod
377
     *
378
     * @return ShippingOption
379
     */
380
    public function setCod($cod)
381
    {
382
        $this->cod = $cod;
383
384
        return $this;
385
    }
386
387
    /**
388
     * @return bool
389
     */
390
    public function isInsurance()
391
    {
392
        return $this->insurance;
393
    }
394
395
    /**
396
     * @param bool $insurance
397
     *
398
     * @return ShippingOption
399
     */
400
    public function setInsurance($insurance)
401
    {
402
        $this->insurance = $insurance;
403
404
        return $this;
405
    }
406
407
    /**
408
     * @return bool
409
     */
410
    public function isNeedsServicePointAccountNumber()
411
    {
412
        return $this->needsServicePointAccountNumber;
413
    }
414
415
    /**
416
     * @param bool $needsServicePointAccountNumber
417
     *
418
     * @return ShippingOption
419
     */
420
    public function setNeedsServicePointAccountNumber($needsServicePointAccountNumber)
421
    {
422
        $this->needsServicePointAccountNumber = $needsServicePointAccountNumber;
423
424
        return $this;
425
    }
426
427
    /**
428
     * @return bool
429
     */
430
    public function isShipperNotification()
431
    {
432
        return $this->shipperNotification;
433
    }
434
435
    /**
436
     * @param bool $shipperNotification
437
     *
438
     * @return ShippingOption
439
     */
440
    public function setShipperNotification($shipperNotification)
441
    {
442
        $this->shipperNotification = $shipperNotification;
443
444
        return $this;
445
    }
446
447
    /**
448
     * @return bool
449
     */
450
    public function isNeedsAdditionalShipperNotification()
451
    {
452
        return $this->needsAdditionalShipperNotification;
453
    }
454
455
    /**
456
     * @param bool $needsAdditionalShipperNotification
457
     *
458
     * @return ShippingOption
459
     */
460
    public function setNeedsAdditionalShipperNotification($needsAdditionalShipperNotification)
461
    {
462
        $this->needsAdditionalShipperNotification = $needsAdditionalShipperNotification;
463
464
        return $this;
465
    }
466
467
    /**
468
     * @return bool
469
     */
470
    public function isAllowsAdditionalShipperNotification()
471
    {
472
        return $this->allowsAdditionalShipperNotification;
473
    }
474
475
    /**
476
     * @param bool $allowsAdditionalShipperNotification
477
     *
478
     * @return ShippingOption
479
     */
480
    public function setAllowsAdditionalShipperNotification($allowsAdditionalShipperNotification)
481
    {
482
        $this->allowsAdditionalShipperNotification = $allowsAdditionalShipperNotification;
483
484
        return $this;
485
    }
486
487
    /**
488
     * @return string
489
     */
490
    public function getContract()
491
    {
492
        return $this->contract;
493
    }
494
495
    /**
496
     * @param string $contract
497
     *
498
     * @return ShippingOption
499
     */
500
    public function setContract($contract)
501
    {
502
        $this->contract = $contract;
503
504
        return $this;
505
    }
506
507
    /**
508
     * @return string
509
     */
510
    public function getOption()
511
    {
512
        return $this->option;
513
    }
514
515
    /**
516
     * @param string $option
517
     *
518
     * @return ShippingOption
519
     */
520
    public function setOption($option)
521
    {
522
        $this->option = $option;
523
524
        return $this;
525
    }
526
527
    /**
528
     * @return string
529
     */
530
    public function getDescription()
531
    {
532
        return $this->description;
533
    }
534
535
    /**
536
     * @param string $description
537
     *
538
     * @return ShippingOption
539
     */
540
    public function setDescription($description)
541
    {
542
        $this->description = $description;
543
544
        return $this;
545
    }
546
}
547