Passed
Push — master ( 2b63db...3a2bd9 )
by Stefan
07:15
created

TimeInTransitResponse::__construct()   F

Complexity

Conditions 13
Paths 1025

Size

Total Lines 43
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 39
CRAP Score 13.0196

Importance

Changes 3
Bugs 1 Features 1
Metric Value
c 3
b 1
f 1
dl 0
loc 43
ccs 39
cts 41
cp 0.9512
rs 2.7716
cc 13
eloc 28
nc 1025
nop 1
crap 13.0196

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Ups\Entity;
4
5
class TimeInTransitResponse
6
{
7
    /**
8
     * @var
9
     */
10
    public $PickupDate;
11
12
    /**
13
     * @var AddressArtifactFormat
14
     */
15
    public $TransitFrom;
16
17
    /**
18
     * @var AddressArtifactFormat
19
     */
20
    public $TransitTo;
21
22
    /**
23
     * @var
24
     */
25
    public $DocumentsOnlyIndicator;
26
27
    /**
28
     * @var
29
     */
30
    public $AutoDutyCode;
31
32
    /**
33
     * @var ShipmentWeight
34
     */
35
    public $ShipmentWeight;
36
37
    /**
38
     * @var Charges
39
     */
40
    public $InvoiceLineTotal;
41
42
    /**
43
     * @var
44
     */
45
    public $Disclaimer;
46
47
    /**
48
     * @var array
49
     */
50
    public $ServiceSummary;
51
52
    /**
53
     * @var
54
     */
55
    public $MaximumListSize;
56
57
    /**
58
     * @param null $response
59
     */
60 3
    public function __construct($response = null)
61
    {
62 3
        $this->TransitFrom = new Address();
63 3
        $this->TransitTo = new Address();
64 3
        $this->ShipmentWeight = new ShipmentWeight();
65 3
        $this->InvoiceLineTotal = new Charges();
66 3
        $this->ServiceSummary = [];
67
68 3
        if (null != $response) {
69 3
            if (isset($response->PickupDate)) {
70 3
                $this->PickupDate = $response->PickupDate;
71 3
            }
72 3
            if (isset($response->TransitFrom->AddressArtifactFormat)) {
73 3
                $this->TransitFrom = new AddressArtifactFormat($response->TransitFrom->AddressArtifactFormat);
74 3
            }
75 3
            if (isset($response->TransitTo->AddressArtifactFormat)) {
76 3
                $this->TransitTo = new AddressArtifactFormat($response->TransitTo->AddressArtifactFormat);
77 3
            }
78 3
            if (isset($response->DocumentsOnlyIndicator)) {
79
                $this->DocumentsOnlyIndicator = $response->DocumentsOnlyIndicator;
80
            }
81 3
            if (isset($response->AutoDutyCode)) {
82 3
                $this->AutoDutyCode = $response->AutoDutyCode;
83 3
            }
84 3
            if (isset($response->ShipmentWeight)) {
85 3
                $this->ShipmentWeight = new ShipmentWeight($response->ShipmentWeight);
86 3
            }
87 3
            if (isset($response->InvoiceLineTotal)) {
88 3
                $this->InvoiceLineTotal = new Charges($response->InvoiceLineTotal);
89 3
            }
90 3
            if (isset($response->Disclaimer)) {
91 3
                $this->Disclaimer = $response->Disclaimer;
92 3
            }
93 3
            if (isset($response->ServiceSummary)) {
94 3
                foreach ($response->ServiceSummary as $serviceSummary) {
95 3
                    $this->ServiceSummary[] = new ServiceSummary($serviceSummary);
96 3
                }
97 3
            }
98 3
            if (isset($response->MaximumListSize)) {
99 3
                $this->MaximumListSize = $response->MaximumListSize;
100 3
            }
101 3
        }
102 3
    }
103
}
104