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

LocationSearchCriteria::getMaximumListSize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Ups\Entity;
4
5
use DOMDocument;
6
use DOMElement;
7
use Exception as BaseException;
8
use Ups\NodeInterface;
9
10
class LocationSearchCriteria implements NodeInterface
11
{
12
    /**
13
     * @var AccessPointSearch
14
     */
15
    private $accessPointSearch;
16
17
    /**
18
     * @var
19
     */
20
    private $maximumListSize;
21
22
    /**
23
     * @return AccessPointSearch
24
     */
25 3
    public function getAccessPointSearch()
26
    {
27 3
        return $this->accessPointSearch;
28
    }
29
30
    /**
31
     * @param AccessPointSearch $accessPointSearch
32
     */
33 2
    public function setAccessPointSearch(AccessPointSearch $accessPointSearch)
34
    {
35 2
        $this->accessPointSearch = $accessPointSearch;
36 2
    }
37
38
    /**
39
     * @param null|DOMDocument $document
40
     *
41
     * @return DOMElement
42
     */
43 3
    public function toNode(DOMDocument $document = null)
44
    {
45 3
        if (null === $document) {
46
            $document = new DOMDocument();
47
        }
48
49 3
        $node = $document->createElement('LocationSearchCriteria');
50
51 3
        if ($this->getAccessPointSearch()) {
52 2
            $node->appendChild($this->getAccessPointSearch()->toNode($document));
53 2
        }
54
55 3
        if ($this->getMaximumListSize()) {
56 2
            $node->appendChild($document->createElement('MaximumListSize', $this->getMaximumListSize()));
57 2
        }
58
59 3
        return $node;
60
    }
61
62
    /**
63
     * @return mixed
64
     */
65 3
    public function getMaximumListSize()
66
    {
67 3
        return $this->maximumListSize;
68
    }
69
70
    /**
71
     * @param mixed $maximumListSize
72
     *
73
     * @throws BaseException
74
     */
75 2 View Code Duplication
    public function setMaximumListSize($maximumListSize)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
76
    {
77 2
        $maximumListSize = (int)$maximumListSize;
78
79 2
        if ($maximumListSize < 1 || $maximumListSize > 50) {
80
            throw new BaseException('Maximum list size: If present, indicates the maximum number of locations the client wishes to receive in response; ranges from 1 to 50 with a default value of 10');
81
        }
82
83 2
        $this->maximumListSize = $maximumListSize;
84 2
    }
85
}
86