Response::addShipment()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
rs 9.6666
1
<?php namespace SimpleUPS\Track;
2
3
use SimpleUPS\Shipment;
4
5
/**
6
 * @internal
7
 */
8
abstract class Response extends \SimpleUPS\Api\Response
9
{
10
11
    private
12
        /* @var Shipment $shipments */
13
        $shipments;
14
15
    /**
16
     * @param Shipment $shipment
17
     *
18
     * @return Response
19
     */
20
    public function addShipment(Shipment $shipment)
21
    {
22
        if ($this->shipments === null) {
23
            $this->shipments = array();
24
        }
25
26
        $this->shipments[] = $shipment;
27
        return $this;
28
    }
29
30
    /**
31
     * @return Shipment[]|null
32
     */
33
    public function getShipments()
34
    {
35
        return $this->shipments;
36
    }
37
38
    abstract public function fromXml(\SimpleXMLElement $xml);
39
}