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

Generic::__construct()   F

Complexity

Conditions 18
Paths 9217

Size

Total Lines 61
Code Lines 41

Duplication

Lines 18
Ratio 29.51 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 18
loc 61
rs 3.0398
cc 18
eloc 41
nc 9217
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 Generic
6
{
7
    const AT_VOIDFORMANIFEST = 'VM';
8
    const AT_UNDELIVERABLERETURNS = 'UR';
9
    const AT_INVOICEREMOVALSUCCESSFUL = 'IR';
10
    const AT_TRANSPORTCOMPANYUSPSSCAN = 'TC';
11
    const AT_POSTALSERVICEPOSSESSIONSCAN = 'PS';
12
    const AT_UPSEMAILNOTIFICATIONFAILURE = 'FN';
13
    const AT_DESTINATIONSCAN = 'DS';
14
15
    public $ActivityType;
16
    public $TrackingNumber;
17
    public $ShipperNumber;
18
    public $ShipmentReferenceNumber;
19
    public $PackageReferenceNumber;
20
    public $Service;
21
    public $Activity;
22
    public $BillToAccount;
23
    public $ShipTo;
24
    public $RescheduledDeliveryDate;
25
    public $FailureNotification;
26
    public $Bookmark;
27
28
    public function __construct($response = null)
29
    {
30
        $this->ShipmentReferenceNumber = new ShipmentReferenceNumber();
31
        $this->PackageReferenceNumber = new PackageReferenceNumber();
32
        $this->Service = new Service();
33
        $this->Activity = new Activity();
34
        $this->BillToAccount = new BillToAccount();
35
        $this->ShipTo = new ShipTo();
36
        $this->FailureNotification = new FailureNotification();
37
38
        if (null != $response) {
39
            if (isset($response->ActivityType)) {
40
                $this->ActivityType = $response->ActivityType;
41
            }
42
            if (isset($response->TrackingNumber)) {
43
                $this->TrackingNumber = $response->TrackingNumber;
44
            }
45
            if (isset($response->ShipperNumber)) {
46
                $this->ShipperNumber = $response->ShipperNumber;
47
            }
48 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...
49
                if (is_array($response->ShipmentReferenceNumber)) {
50
                    foreach ($response->ShipmentReferenceNumber as $ShipmentReferenceNumber) {
51
                        $this->ShipmentReferenceNumber[] = new ShipmentReferenceNumber($ShipmentReferenceNumber);
52
                    }
53
                } else {
54
                    $this->ShipmentReferenceNumber[] = new ShipmentReferenceNumber($response->ShipmentReferenceNumber);
55
                }
56
            }
57 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...
58
                if (is_array($response->PackageReferenceNumber)) {
59
                    foreach ($response->PackageReferenceNumber as $PackageReferenceNumber) {
60
                        $this->PackageReferenceNumber[] = new PackageReferenceNumber($PackageReferenceNumber);
61
                    }
62
                } else {
63
                    $this->PackageReferenceNumber[] = new PackageReferenceNumber($response->PackageReferenceNumber);
64
                }
65
            }
66
            if (isset($response->Service)) {
67
                $this->Service->setCode($response->Service->Code);
68
            }
69
            if (isset($response->Activity)) {
70
                $this->Activity = new Activity($response->Activity);
71
            }
72
            if (isset($response->BillToAccount)) {
73
                $this->BillToAccount = new BillToAccount($response->BillToAccount);
74
            }
75
            if (isset($response->ShipTo)) {
76
                $this->ShipTo = new ShipTo($response->ShipTo);
77
            }
78
            if (isset($response->RescheduledDeliveryDate)) {
79
                $this->RescheduledDeliveryDate = $response->RescheduledDeliveryDate;
80
            }
81
            if (isset($response->FailureNotification)) {
82
                $this->FailureNotification = new FailureNotification($response->FailureNotification);
83
            }
84
            if (isset($response->Bookmark)) {
85
                $this->Bookmark = $response->Bookmark;
86
            }
87
        }
88
    }
89
}
90