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

EstimatedArrival::__construct()   F

Complexity

Conditions 15
Paths 8193

Size

Total Lines 44
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 39
CRAP Score 15.1809

Importance

Changes 0
Metric Value
dl 0
loc 44
ccs 39
cts 43
cp 0.907
rs 2.7451
c 0
b 0
f 0
cc 15
eloc 28
nc 8193
nop 1
crap 15.1809

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 EstimatedArrival
6
{
7
    const EA_MONDAY = 'MON';
8
    const EA_TUESDAY = 'TUE';
9
    const EA_WEDNESDAY = 'WEB';
10
    const EA_THUSDAY = 'THU';
11
    const EA_FRIDAY = 'FRI';
12
    const EA_SATURDAY = 'SAT';
13
    // Sunday is an invalid day :-)
14
15
    public $BusinessTransitDays;
16
    public $Time;
17
    public $Arrival;
18
    public $PickupDate;
19
    public $PickupTime;
20
    public $HolidayCount;
21
    public $DelayCount;
22
    public $Date;
23
    public $DayOfWeek;
24
    public $TotalTransitDays;
25
    public $CustomerCenterCutoff;
26
    public $RestDays;
27
28
    /**
29
     * @param \stdClass|null $response
30
     */
31 5
    public function __construct(\stdClass $response = null)
32
    {
33 5
        if (null !== $response) {
34 3
            if (isset($response->BusinessTransitDays)) {
35 3
                $this->BusinessTransitDays = $response->BusinessTransitDays;
36 3
            }
37 3
            if (isset($response->Time)) {
38 3
                $this->Time = $response->Time;
39 3
            }
40 3
            if (isset($response->PickupDate)) {
41 3
                $this->PickupDate = $response->PickupDate;
42 3
            }
43 3
            if (isset($response->PickupTime)) {
44 3
                $this->PickupTime = $response->PickupTime;
45 3
            }
46 3
            if (isset($response->HolidayCount)) {
47 3
                $this->HolidayCount = $response->HolidayCount;
48 3
            }
49 3
            if (isset($response->DelayCount)) {
50 3
                $this->DelayCount = $response->DelayCount;
51 3
            }
52 3
            if (isset($response->Date)) {
53 3
                $this->Date = $response->Date;
54 3
            }
55 3
            if (isset($response->DayOfWeek)) {
56 3
                $this->DayOfWeek = $response->DayOfWeek;
57 3
            }
58 3
            if (isset($response->TotalTransitDays)) {
59 3
                $this->TotalTransitDays = $response->TotalTransitDays;
60 3
            }
61 3
            if (isset($response->CustomerCenterCutoff)) {
62 3
                $this->CustomerCenterCutoff = $response->CustomerCenterCutoff;
63 3
            }
64 3
            if (isset($response->RestDays)) {
65 3
                $this->RestDays = $response->RestDays;
66 3
            }
67 3
            if (isset($response->Arrival)) {
68
                $this->Arrival = new Arrival($response->Arrival);
69
            }
70 3
            if (isset($response->Pickup)) {
71
                $this->Pickup = new Pickup($response->Pickup);
0 ignored issues
show
Bug introduced by
The property Pickup does not seem to exist. Did you mean PickupDate?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
72
            }
73 3
        }
74 5
    }
75
}
76