Passed
Push — master ( 17c5f7...cb633b )
by Stefan
04:29 queued 02:00
created

EstimatedArrivalTrait::build()   F

Complexity

Conditions 10
Paths 257

Size

Total Lines 29
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 24
CRAP Score 10.2918

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 29
ccs 24
cts 28
cp 0.8571
rs 3.1304
c 1
b 0
f 0
cc 10
eloc 18
nc 257
nop 1
crap 10.2918

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
trait EstimatedArrivalTrait
6
{
7
    private $Arrival;
8
    private $Pickup;
9
    private $DayOfWeek;
10
    private $CustomerCenterCutoff;
11
    private $DelayCount;
12
    private $HolidayCount;
13
    private $RestDays;
14
    private $TotalTransitDays;
15
16
    /**
17
     * @param \stdClass|null $response
18
     */
19 3
    public function build(\stdClass $response = null)
20
    {
21 3
        if (null !== $response) {
22 3
            if (isset($response->Arrival)) {
23
                $this->Arrival = new Arrival($response->Arrival);
24
            }
25 3
            if (isset($response->Pickup)) {
26
                $this->Pickup = new Pickup($response->Pickup);
27
            }
28 3
            if (isset($response->HolidayCount)) {
29 3
                $this->HolidayCount = $response->HolidayCount;
30 3
            }
31 3
            if (isset($response->DelayCount)) {
32 3
                $this->DelayCount = $response->DelayCount;
33 3
            }
34 3
            if (isset($response->DayOfWeek)) {
35 3
                $this->DayOfWeek = $response->DayOfWeek;
36 3
            }
37 3
            if (isset($response->TotalTransitDays)) {
38 3
                $this->TotalTransitDays = $response->TotalTransitDays;
39 3
            }
40 3
            if (isset($response->CustomerCenterCutoff)) {
41 3
                $this->CustomerCenterCutoff = $response->CustomerCenterCutoff;
42 3
            }
43 3
            if (isset($response->RestDays)) {
44 3
                $this->RestDays = $response->RestDays;
45 3
            }
46 3
        }
47 3
    }
48
49
    /**
50
     * @return Arrival
51
     */
52
    public function getArrival()
53
    {
54
        return $this->Arrival;
55
    }
56
57
    /**
58
     * @param Arrival $Arrival
59
     */
60
    public function setArrival($Arrival)
61
    {
62
        $this->Arrival = $Arrival;
63
    }
64
65
    /**
66
     * @return Pickup
67
     */
68
    public function getPickup()
69
    {
70
        return $this->Pickup;
71
    }
72
73
    /**
74
     * @param Pickup $Pickup
75
     */
76
    public function setPickup($Pickup)
77
    {
78
        $this->Pickup = $Pickup;
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    public function getDayOfWeek()
85
    {
86
        return $this->DayOfWeek;
87
    }
88
89
    /**
90
     * @param string $DayOfWeek
91
     */
92
    public function setDayOfWeek($DayOfWeek)
93
    {
94
        $this->DayOfWeek = $DayOfWeek;
95
    }
96
97
    /**
98
     * @return string
99
     */
100
    public function getCustomerCenterCutoff()
101
    {
102
        return $this->CustomerCenterCutoff;
103
    }
104
105
    /**
106
     * @param string $CustomerCenterCutoff
107
     */
108
    public function setCustomerCenterCutoff($CustomerCenterCutoff)
109
    {
110
        $this->CustomerCenterCutoff = $CustomerCenterCutoff;
111
    }
112
113
    /**
114
     * @return string
115
     */
116
    public function getDelayCount()
117
    {
118
        return $this->DelayCount;
119
    }
120
121
    /**
122
     * @param string $DelayCount
123
     */
124
    public function setDelayCount($DelayCount)
125
    {
126
        $this->DelayCount = $DelayCount;
127
    }
128
129
    /**
130
     * @return string
131
     */
132
    public function getHolidayCount()
133
    {
134
        return $this->HolidayCount;
135
    }
136
137
    /**
138
     * @param string $HolidayCount
139
     */
140
    public function setHolidayCount($HolidayCount)
141
    {
142
        $this->HolidayCount = $HolidayCount;
143
    }
144
145
    /**
146
     * @return string
147
     */
148
    public function getRestDays()
149
    {
150
        return $this->RestDays;
151
    }
152
153
    /**
154
     * @param string $RestDays
155
     */
156
    public function setRestDays($RestDays)
157
    {
158
        $this->RestDays = $RestDays;
159
    }
160
161
    /**
162
     * @return string
163
     */
164
    public function getTotalTransitDays()
165
    {
166
        return $this->TotalTransitDays;
167
    }
168
169
    /**
170
     * @param string $TotalTransitDays
171
     */
172
    public function setTotalTransitDays($TotalTransitDays)
173
    {
174
        $this->TotalTransitDays = $TotalTransitDays;
175
    }
176
}
177