Response::getShippingMethods()   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\Rates;
2
3
class Response extends \SimpleUPS\Api\Response
4
{
5
    private
6
        /* @var ShippingMethod[] $shippingMethods */
7
        $shippingMethods;
8
9
    /**
10
     * @internal
11
     *
12
     * @param ShippingMethod $shippingMethod
13
     *
14
     * @return Response
15
     */
16
    public function addShippingMethod(ShippingMethod $shippingMethod)
17
    {
18
        if ($this->shippingMethods === null) {
19
            $this->shippingMethods = array();
20
        }
21
22
        $this->shippingMethods[] = $shippingMethod;
23
        return $this;
24
    }
25
26
    /**
27
     * @return ShippingMethod[]|null
28
     */
29
    public function getShippingMethods()
30
    {
31
        return $this->shippingMethods;
32
    }
33
34
    /**
35
     * @param \SimpleXMLElement $xml
36
     *
37
     * @return Response
38
     */
39
    public function fromXml(\SimpleXMLElement $xml)
40
    {
41
        foreach ($xml->RatedShipment as $ratedShipment) {
42
            $this->addShippingMethod(ShippingMethod::fromXml($ratedShipment));
43
        }
44
45
        return $this;
46
    }
47
}