Completed
Pull Request — master (#86)
by
unknown
03:35
created

Exception::__construct()   F

Complexity

Conditions 19
Paths > 20000

Size

Total Lines 60
Code Lines 39

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 60
rs 3.1212
cc 19
eloc 39
nc 32769
nop 1

How to fix   Long Method    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 Exception
6
{
7
    public $PackageReferenceNumber;
8
    public $ShipmentReferenceNumber;
9
    public $TrackingNumber;
10
    public $Date;
11
    public $Time;
12
    public $UpdatedAddress;
13
    public $StatusCode;
14
    public $StatusDescription;
15
    public $ReasonCode;
16
    public $ReasonDescription;
17
    public $Resolution;
18
    public $RescheduledDeliveryDate;
19
    public $RescheduledDeliveryTime;
20
    public $ActivityLocation;
21
    public $BillToAccount;
22
23
    public function __construct($response = null)
24
    {
25
        $this->PackageReferenceNumber = [];
26
        $this->ShipmentReferenceNumber = [];
27
        $this->Resolution = new Resolution();
28
        $this->ActivityLocation = new ActivityLocation();
29
        $this->BillToAccount = new BillToAccount();
30
31
        if (null != $response) {
32
            if (isset($response->PackageReferenceNumber)) {
33
                foreach ($response->PackageReferenceNumber as $PackageReferenceNumber) {
34
                    $this->PackageReferenceNumber[] = new PackageReferenceNumber($PackageReferenceNumber);
35
                }
36
            }
37
            if (isset($response->ShipmentReferenceNumber)) {
38
                foreach ($response->ShipmentReferenceNumber as $ShipmentReferenceNumber) {
39
                    $this->ShipmentReferenceNumber[] = new ShipmentReferenceNumber($ShipmentReferenceNumber);
40
                }
41
            }
42
            if (isset($response->TrackingNumber)) {
43
                $this->TrackingNumber = $response->TrackingNumber;
44
            }
45
            if (isset($response->Date)) {
46
                $this->Date = $response->Date;
47
            }
48
            if (isset($response->Time)) {
49
                $this->Time = $response->Time;
50
            }
51
            if (isset($response->UpdatedAddress)) {
52
                $this->UpdatedAddress = new UpdatedAddress($response->UpdatedAddress);
53
            }
54
            if (isset($response->StatusCode)) {
55
                $this->StatusCode = $response->StatusCode;
56
            }
57
            if (isset($response->StatusDescription)) {
58
                $this->StatusDescription = $response->StatusDescription;
59
            }
60
            if (isset($response->ReasonCode)) {
61
                $this->ReasonCode = $response->ReasonCode;
62
            }
63
            if (isset($response->ReasonDescription)) {
64
                $this->ReasonDescription = $response->ReasonDescription;
65
            }
66
            if (isset($response->Resolution)) {
67
                $this->Resolution = new Resolution($response->Resolution);
68
            }
69
            if (isset($response->RescheduledDeliveryDate)) {
70
                $this->RescheduledDeliveryDate = $response->RescheduledDeliveryDate;
71
            }
72
            if (isset($response->RescheduledDeliveryTime)) {
73
                $this->RescheduledDeliveryTime = $response->RescheduledDeliveryTime;
74
            }
75
            if (isset($response->ActivityLocation)) {
76
                $this->ActivityLocation = new ActivityLocation($response->ActivityLocation);
77
            }
78
            if (isset($response->BillToAccount)) {
79
                $this->BillToAccount = new BillToAccount($response->BillToAccount);
80
            }
81
        }
82
    }
83
}
84