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

EstimatedArrival::__construct()   F

Complexity

Conditions 11
Paths 513

Size

Total Lines 32
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 132

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 32
ccs 0
cts 31
cp 0
rs 3.1764
c 1
b 1
f 0
cc 11
eloc 20
nc 513
nop 1
crap 132

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\Rate;
4
5
use Ups\Entity\Arrival;
6
use Ups\Entity\Pickup;
7
8
class EstimatedArrival
9
{
10
    public $BusinessTransitDays;
11
    public $Arrival;
12
    public $Pickup;
13
    public $DayOfWeek;
14
    public $CustomerCenterCutoff;
15
    public $DelayCount;
16
    public $HolidayCount;
17
    public $RestDays;
18
    public $TotalTransitDays;
19
20
    /**
21
     * @param \stdClass|null $response
22
     */
23
    public function __construct(\stdClass $response = null)
24
    {
25
        if (null !== $response) {
26
            if (isset($response->BusinessTransitDays)) {
27
                $this->BusinessTransitDays = $response->BusinessTransitDays;
28
            }
29
            if (isset($response->Arrival)) {
30
                $this->Arrival = new Arrival($response->Arrival);
31
            }
32
            if (isset($response->Pickup)) {
33
                $this->Pickup = new Pickup($response->Pickup);
34
            }
35
            if (isset($response->HolidayCount)) {
36
                $this->HolidayCount = $response->HolidayCount;
37
            }
38
            if (isset($response->DelayCount)) {
39
                $this->DelayCount = $response->DelayCount;
40
            }
41
            if (isset($response->DayOfWeek)) {
42
                $this->DayOfWeek = $response->DayOfWeek;
43
            }
44
            if (isset($response->TotalTransitDays)) {
45
                $this->TotalTransitDays = $response->TotalTransitDays;
46
            }
47
            if (isset($response->CustomerCenterCutoff)) {
48
                $this->CustomerCenterCutoff = $response->CustomerCenterCutoff;
49
            }
50
            if (isset($response->RestDays)) {
51
                $this->RestDays = $response->RestDays;
52
            }
53
        }
54
    }
55
}
56