ShipmentType::setDescription()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 9.4285
1
<?php namespace SimpleUPS\Track;
2
3
/**
4
 * @internal
5
 */
6
class ShipmentType extends \SimpleUPS\Model
7
{
8
    const
9
        TYPE_SMALL_PACKAGE = 1,
10
        TYPE_FREIGHT = 2,
11
        TYPE_MAIL_INNOVATION = 3;
12
13
    private
14
        /* @var string $code */
15
        $code,
16
17
        /* @var string $description */
18
        $description;
19
20
    /**
21
     * @param string $code
22
     *
23
     * @return ShipmentType
24
     */
25
    public function setCode($code)
26
    {
27
        $this->code = (string)$code;
28
        return $this;
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function getCode()
35
    {
36
        return $this->code;
37
    }
38
39
    /**
40
     * @param string $description
41
     *
42
     * @return ShipmentType
43
     */
44
    public function setDescription($description)
45
    {
46
        $this->description = (string)$description;
47
        return $this;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getDescription()
54
    {
55
        return $this->description;
56
    }
57
58
    /**
59
     * @param \SimpleXMLElement $xml
60
     *
61
     * @return ShipmentType
62
     */
63
    public static function fromXml(\SimpleXMLElement $xml)
64
    {
65
        $shipmentType = new ShipmentType();
66
        $shipmentType->setIsResponse();
67
        $shipmentType
68
            ->setCode($xml->Code)
69
            ->setDescription($xml->Description);
70
71
        return $shipmentType;
72
    }
73
}