StatusType::isManifestPickup()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php namespace SimpleUPS\Track\SmallPackage;
2
3
/**
4
 * A status type of an activity
5
 * @since 1.0
6
 */
7
class StatusType extends \SimpleUPS\Model
8
{
9
10
    private
11
        $CODE_IN_TRANSIT = 'L',
12
        $CODE_DELIVERED = 'D',
13
        $CODE_EXCEPTION = 'X',
14
        $CODE_PICKUP = 'P',
15
        $CODE_MANIFEST_PICKUP = 'M';
16
17
    private
18
        /* @var string $code */
19
        $code,
20
21
        /* @var string $description */
22
        $description;
23
24
    /**
25
     * @internal
26
     *
27
     * @param string $code
28
     *
29
     * @return Status
30
     */
31
    public function setCode($code)
32
    {
33
        $this->code = (string)$code;
34
        return $this;
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    public function getCode()
41
    {
42
        return $this->code;
43
    }
44
45
    /**
46
     * @internal
47
     *
48
     * @param string $description
49
     *
50
     * @return Status
51
     */
52
    public function setDescription($description)
53
    {
54
        $this->description = (string)$description;
55
        return $this;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getDescription()
62
    {
63
        return $this->description;
64
    }
65
66
    /**
67
     * @return bool
68
     */
69
    public function isInTransit()
70
    {
71
        return $this->getCode() == $this->CODE_IN_TRANSIT;
72
    }
73
74
    /**
75
     * @return bool
76
     */
77
    public function isDelivered()
78
    {
79
        return $this->getCode() == $this->CODE_DELIVERED;
80
    }
81
82
    /**
83
     * @return bool
84
     */
85
    public function isException()
86
    {
87
        return $this->getCode() == $this->CODE_EXCEPTION;
88
    }
89
90
    /**
91
     * @return bool
92
     */
93
    public function isPickup()
94
    {
95
        return $this->getCode() == $this->CODE_PICKUP;
96
    }
97
98
    /**
99
     * @return bool
100
     */
101
    public function isManifestPickup()
102
    {
103
        return $this->getCode() == $this->CODE_MANIFEST_PICKUP;
104
    }
105
106
    /**
107
     * @internal
108
     *
109
     * @param \SimpleXMLElement $xml
110
     *
111
     * @return StatusType
112
     */
113 View Code Duplication
    public static function fromXml(\SimpleXMLElement $xml)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
114
    {
115
        $statusType = new StatusType();
116
        $statusType->setIsResponse();
117
118
        if (isset($xml->Code)) {
119
            $statusType->setCode((string)$xml->Code);
120
        }
121
122
        if (isset($xml->Description)) {
123
            $statusType->setDescription((string)$xml->Description);
124
        }
125
126
        return $statusType;
127
    }
128
}