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

Delivery::__construct()   F

Complexity

Conditions 17
Paths 4609

Size

Total Lines 57
Code Lines 38

Duplication

Lines 18
Ratio 31.58 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 18
loc 57
rs 3.3193
cc 17
eloc 38
nc 4609
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 Delivery
6
{
7
    public $PackageReferenceNumber;
8
    public $ShipmentReferenceNumber;
9
    public $TrackingNumber;
10
    public $ShipperNumber;
11
    public $Date;
12
    public $Time;
13
    public $DriverRelease;
14
    public $ActivityLocation;
15
    public $DeliveryLocation;
16
    public $COD;
17
    public $BillToAccount;
18
19
    public function __construct($response = null)
20
    {
21
        $this->ShipmentReferenceNumber = new ShipmentReferenceNumber();
22
        $this->PackageReferenceNumber = new PackageReferenceNumber();
23
        $this->ActivityLocation = new ActivityLocation();
24
        $this->DeliveryLocation = new DeliveryLocation();
25
        $this->COD = new COD();
26
        $this->BillToAccount = new BillToAccount();
27
28
        if (null != $response) {
29 View Code Duplication
            if (isset($response->PackageReferenceNumber)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
                if (is_array($response->PackageReferenceNumber)) {
31
                    foreach ($response->PackageReferenceNumber as $PackageReferenceNumber) {
32
                        $this->PackageReferenceNumber[] = new PackageReferenceNumber($PackageReferenceNumber);
33
                    }
34
                } else {
35
                    $this->PackageReferenceNumber[] = new PackageReferenceNumber($response->PackageReferenceNumber);
36
                }
37
            }
38 View Code Duplication
            if (isset($response->ShipmentReferenceNumber)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
                if (is_array($response->ShipmentReferenceNumber)) {
40
                    foreach ($response->ShipmentReferenceNumber as $ShipmentReferenceNumber) {
41
                        $this->ShipmentReferenceNumber[] = new ShipmentReferenceNumber($ShipmentReferenceNumber);
42
                    }
43
                } else {
44
                    $this->ShipmentReferenceNumber[] = new ShipmentReferenceNumber($response->ShipmentReferenceNumber);
45
                }
46
            }
47
            if (isset($response->TrackingNumber)) {
48
                $this->TrackingNumber = $response->TrackingNumber;
49
            }
50
            if (isset($response->ShipperNumber)) {
51
                $this->ShipperNumber = $response->ShipperNumber;
52
            }
53
            if (isset($response->Date)) {
54
                $this->Date = $response->Date;
55
            }
56
            if (isset($response->Time)) {
57
                $this->Time = $response->Time;
58
            }
59
            if (isset($response->DriverRelease)) {
60
                $this->DriverRelease = $response->DriverRelease;
61
            }
62
            if (isset($response->ActivityLocation)) {
63
                $this->ActivityLocation = new ActivityLocation($response->ActivityLocation);
64
            }
65
            if (isset($response->DeliveryLocation)) {
66
                $this->DeliveryLocation = new DeliveryLocation($response->DeliveryLocation);
67
            }
68
            if (isset($response->COD)) {
69
                $this->COD = new COD($response->COD);
70
            }
71
            if (isset($response->BillToAccount)) {
72
                $this->BillToAccount = new BillToAccount($response->BillToAccount);
73
            }
74
        }
75
    }
76
}
77