Response   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addShippingMethod() 0 9 2
A getShippingMethods() 0 4 1
A fromXml() 0 8 2
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
}