Status::fromXml()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 10
rs 9.4285
1
<?php namespace SimpleUPS\Track;
2
3
/**
4
 * The status of a tracked shipment
5
 * @since 1.0
6
 */
7
class Status extends \SimpleUPS\Model
8
{
9
10
    public static
11
        $CODE_BILLING_INFO_RECEIVED = 1,
12
        $CODE_IN_TRANSIT = 2,
13
        $CODE_EXCEPTION = 3,
14
        $CODE_DELIVERED_ORIGIN_CFS = 4,
15
        $CODE_DELIVERED_DESTINATION_CFS = 5,
16
        $CODE_WAREHOUSING = 6,
17
        $CODE_OUT_FOR_DELIVERY = 7,
18
        $CODE_DELIVERED = 11,
19
        $CODE_NOT_AVAILABLE1 = 111,
20
        $CODE_NOT_AVAILABLE2 = 222;
21
22
    private
23
        /* @var integer $code */
24
        $code,
25
26
        /* @var string $description */
27
        $description;
28
29
    /**
30
     * @internal
31
     *
32
     * @param integer $code
33
     *
34
     * @return Status
35
     */
36
    public function setCode($code)
37
    {
38
        $this->code = (int)$code;
39
        return $this;
40
    }
41
42
    /**
43
     * Get the code for this status
44
     * @return integer
45
     */
46
    public function getCode()
47
    {
48
        return $this->code;
49
    }
50
51
    /**
52
     * @internal
53
     *
54
     * @param string $description
55
     *
56
     * @return Status
57
     */
58
    public function setDescription($description)
59
    {
60
        $this->description = (string)$description;
61
        return $this;
62
    }
63
64
    /**
65
     * Textual representation of the status
66
     * @return string
67
     */
68
    public function getDescription()
69
    {
70
        return $this->description;
71
    }
72
73
    /**
74
     * @internal
75
     *
76
     * @param \SimpleXMLElement $xml
77
     *
78
     * @return Status
79
     */
80
    public static function fromXml(\SimpleXMLElement $xml)
81
    {
82
        $status = new Status();
83
        $status->setIsResponse();
84
        $status
85
            ->setCode($xml->Code)
86
            ->setDescription($xml->Description);
87
88
        return $status;
89
    }
90
}