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

RateInformation   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 61.76%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 12
c 2
b 0
f 0
lcom 1
cbo 0
dl 0
loc 90
ccs 21
cts 34
cp 0.6176
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 4
A toNode() 0 18 4
A getNegotiatedRatesIndicator() 0 4 1
A setNegotiatedRatesIndicator() 0 6 1
A getRateChartIndicator() 0 4 1
A setRateChartIndicator() 0 6 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