Completed
Push — master ( 4b31fe...fd90eb )
by Stefan
05:33
created

UPSFiled::toNode()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3.072

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 15
ccs 8
cts 10
cp 0.8
rs 9.4285
cc 3
eloc 8
nc 4
nop 1
crap 3.072
1
<?php
2
3
namespace Ups\Entity;
4
5
use DOMDocument;
6
use DOMElement;
7
use Ups\NodeInterface;
8
9
class UPSFiled implements NodeInterface
10
{
11
    /**
12
     * @var POA
13
     */
14
    private $poa;
15
16
    /**
17
     * @param null|object $attributes
18
     */
19 3
    public function __construct($attributes = null)
20
    {
21 3
        if (null !== $attributes) {
22 3
            if (isset($attributes->POA)) {
23 3
                $this->setPOA(new POA($attributes->POA));
24 3
            }
25 3
        }
26 3
    }
27
28
    /**
29
     * @param null|DOMDocument $document
30
     *
31
     * @return DOMElement
32
     */
33 1
    public function toNode(DOMDocument $document = null)
34
    {
35 1
        if (null === $document) {
36
            $document = new DOMDocument();
37
        }
38
39 1
        $node = $document->createElement('UPSFiled');
40
41 1
        $poa = $this->getPOA();
42 1
        if (isset($poa)) {
43 1
            $node->appendChild($poa->toNode($document));
44 1
        }
45
46 1
        return $node;
47
    }
48
49
    /**
50
     * @return POA
51
     */
52 3
    public function getPOA()
53
    {
54 3
        return $this->poa;
55
    }
56
57
    /**
58
     * @return string
59
     */
60 3
    public function setPOA(POA $poa)
61
    {
62 3
        $this->poa = $poa;
63
64 3
        return $this;
65
    }
66
}
67