Response::getShipments()   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\Track\SmallPackage;
2
3
/**
4
 * @internal
5
 */
6
class Response extends \SimpleUPS\Track\Response
7
{
8
9
    private
10
        /* @var Shipment $shipments */
11
        $shipments;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
12
13
    /**
14
     * @param Shipment $shipment
15
     *
16
     * @return Response
17
     */
18
    public function addShipment(Shipment $shipment)
19
    {
20
        if ($this->shipments === null) {
21
            $this->shipments = array();
22
        }
23
24
        $this->shipments[] = $shipment;
25
        return $this;
26
    }
27
28
    /**
29
     * @return Shipment[]|null
30
     */
31
    public function getShipments()
32
    {
33
        return $this->shipments;
34
    }
35
36
    /**
37
     * @param \SimpleXMLElement $xml
38
     *
39
     * @return Response
40
     */
41
    public function fromXml(\SimpleXMLElement $xml)
42
    {
43
        foreach ($xml->Shipment as $xml) {
44
            $this->addShipment(Shipment::fromXml($xml));
45
        }
46
47
        return $this;
48
    }
49
50
}