Completed
Push — master ( fd90eb...52b814 )
by Stefan
04:00
created

RateInformation::setRateChartIndicator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Ups\Entity;
4
5
use DOMDocument;
6
use DOMElement;
7
use Ups\NodeInterface;
8
9
class RateInformation implements NodeInterface
10
{
11
    /** @var bool */
12
    private $negotiatedRatesIndicator;
13
14
    /** @var bool */
15
    private $rateChartIndicator;
16
17
    /**
18
     * @param null|object $attributes
19
     */
20 1
    public function __construct($attributes = null)
21
    {
22 1
        $this->setNegotiatedRatesIndicator(false);
23 1
        $this->setRateChartIndicator(false);
24
25 1
        if (null != $attributes) {
26
            if (isset($attributes->NegotiatedRatesIndicator)) {
27
                $this->setNegotiatedRatesIndicator(true);
28
            }
29
            if (isset($attributes->RateChartIndicator)) {
30
                $this->setRateChartIndicator(true);
31
            }
32
        }
33 1
    }
34
35
    /**
36
     * @param null|DOMDocument $document
37
     *
38
     * @return DOMElement
39
     */
40 1
    public function toNode(DOMDocument $document = null)
41
    {
42 1
        if (null === $document) {
43
            $document = new DOMDocument();
44
        }
45
46 1
        $node = $document->createElement('RateInformation');
47
48 1
        if ($this->getNegotiatedRatesIndicator()) {
49
            $node->appendChild($document->createElement('NegotiatedRatesIndicator'));
50
        }
51
52 1
        if ($this->getRateChartIndicator()) {
53
            $node->appendChild($document->createElement('RateChartIndicator'));
54
        }
55
56 1
        return $node;
57
    }
58
59
    /**
60
     * @return bool
61
     */
62 1
    public function getNegotiatedRatesIndicator()
63
    {
64 1
        return $this->negotiatedRatesIndicator;
65
    }
66
67
    /**
68
     * @param $value
69
     *
70
     * @return $this
71
     */
72 1
    public function setNegotiatedRatesIndicator($value)
73
    {
74 1
        $this->negotiatedRatesIndicator = $value;
75
76 1
        return $this;
77
    }
78
79
    /**
80
     * @return bool
81
     */
82 1
    public function getRateChartIndicator()
83
    {
84 1
        return $this->rateChartIndicator;
85
    }
86
87
    /**
88
     * @param $value
89
     *
90
     * @return $this
91
     */
92 1
    public function setRateChartIndicator($value)
93
    {
94 1
        $this->rateChartIndicator = $value;
95
96 1
        return $this;
97
    }
98
}
99