Passed
Pull Request — master (#157)
by Rudger
03:23
created

SearchFilter::toNode()   B

Complexity

Conditions 6
Paths 32

Size

Total Lines 28
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 28
ccs 0
cts 18
cp 0
rs 8.439
cc 6
eloc 13
nc 32
nop 1
crap 42
1
<?php
2
3
namespace Ups\Entity;
4
5
use DOMDocument;
6
use DOMElement;
7
use DOMNode;
8
use Ups\NodeInterface;
9
10
class SearchFilter implements NodeInterface
11
{
12
    /**
13
     * @var bool
14
     */
15
    private $dcrIndicator;
16
17
    /**
18
     * @var bool
19
     */
20
    private $shippingAvailabilityIndicator;
21
22
    /**
23
     * @var int
24
     */
25
    private $shipperPreparationDelay;
26
27
    /**
28
     * @var string
29
     */
30
    private $clickAndCollectSortWithDistance;
31
32
    /**
33
     * @param null|DOMDocument $document
34
     *
35
     * @return DOMNode
36
     */
37
    public function toNode(DOMDocument $document = null)
38
    {
39
        if (null === $document) {
40
            $document = new DOMDocument();
41
        }
42
        /** @var DOMElement $node */
43
        $node = $document->createElement('SearchFilter');
44
45
        if ($this->getDcrIndicator()) {
46
            $node->appendChild($document->createElement('DCRIndicator'));
47
        }
48
49
        if ($this->getShippingAvailabilityIndicator()) {
50
            $node->appendChild($document->createElement('ShippingAvailabilityIndicator'));
51
        }
52
53
54
        if ($this->getShipperPreparationDelay()) {
55
            $node->appendChild($document->createElement('ShipperPreparationDelay', strval($this->getShipperPreparationDelay())));
56
        }
57
58
59
        if ($this->getClickAndCollectSortWithDistance()) {
60
            $node->appendChild($document->createElement('ClickAndCollectSortWithDistance', strval($this->getClickAndCollectSortWithDistance())));
61
        }
62
63
        return $node;
64
    }
65
66
    /**
67
     * @return bool
68
     */
69
    public function getDcrIndicator()
70
    {
71
        return $this->dcrIndicator;
72
    }
73
74
    /**
75
     * @param bool $dcrIndicator
76
     */
77
    public function setDcrIndicator($dcrIndicator)
78
    {
79
        $this->dcrIndicator = $dcrIndicator;
80
    }
81
82
    /**
83
     * @return bool
84
     */
85
    public function getShippingAvailabilityIndicator()
86
    {
87
        return $this->shippingAvailabilityIndicator;
88
    }
89
90
    /**
91
     * @param bool $shippingAvailabilityIndicator
92
     */
93
    public function setShippingAvailabilityIndicator($shippingAvailabilityIndicator)
94
    {
95
        $this->shippingAvailabilityIndicator = $shippingAvailabilityIndicator;
96
    }
97
98
    /**
99
     * @return int
100
     */
101
    public function getShipperPreparationDelay()
102
    {
103
        return $this->shipperPreparationDelay;
104
    }
105
106
    /**
107
     * @param int $shipperPreparationDelay
108
     */
109
    public function setShipperPreparationDelay($shipperPreparationDelay)
110
    {
111
        $this->shipperPreparationDelay = $shipperPreparationDelay;
112
    }
113
114
    /**
115
     * @return string
116
     */
117
    public function getClickAndCollectSortWithDistance()
118
    {
119
        return $this->clickAndCollectSortWithDistance;
120
    }
121
122
    /**
123
     * @param string $clickAndCollectSortWithDistance
124
     */
125
    public function setClickAndCollectSortWithDistance($clickAndCollectSortWithDistance)
126
    {
127
        $this->clickAndCollectSortWithDistance = $clickAndCollectSortWithDistance;
128
    }
129
}