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

Delivery   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 72
Duplicated Lines 25 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 17
c 2
b 0
f 0
lcom 0
cbo 6
dl 18
loc 72
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
F __construct() 18 57 17

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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