ShipmentType   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 68
rs 10
wmc 5
lcom 1
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setCode() 0 5 1
A getCode() 0 4 1
A setDescription() 0 5 1
A getDescription() 0 4 1
A fromXml() 0 10 1
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
}