Failed Conditions
Pull Request — feature/init (#3)
by Yo
01:46
created

CollectionDoc::getMaxItem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Yoanm\JsonRpcServerDoc\Model\Type;
3
4
/**
5
 * Class CollectionDoc
6
 */
7
class CollectionDoc extends TypeDoc
8
{
9
    /*** Validation ***/
10
    /** @var TypeDoc[] */
11
    private $siblingList = [];
12
    /** @var null|int */
13
    private $minItem = null;
14
    /** @var null|int */
15
    private $maxItem = null;
16
    /** @var bool */
17
    private $allowExtraSibling = true;
18
    /** @var bool */
19
    private $allowMissingSibling = true;
20
21
    /**
22
     * @param TypeDoc $doc
23
     *
24
     * @return CollectionDoc
25
     */
26
    public function addSibling(TypeDoc $doc) : CollectionDoc
27
    {
28
        $this->siblingList[] = $doc;
29
30
        return $this;
31
    }
32
33
    /**
34
     * @param null|int $minItem
35
     *
36
     * @return CollectionDoc
37
     */
38
    public function setMinItem($minItem) : CollectionDoc
39
    {
40
        if (null !== $minItem && !is_int($minItem)) {
0 ignored issues
show
introduced by
The condition is_int($minItem) is always true.
Loading history...
41
            throw new \InvalidArgumentException('minItem must be either null or an integer.');
42
        }
43
44
        $this->minItem = $minItem;
45
46
        return $this;
47
    }
48
49
    /**
50
     * @param null|int $maxItem
51
     *
52
     * @return CollectionDoc
53
     */
54
    public function setMaxItem($maxItem) : CollectionDoc
55
    {
56
        if (null !== $maxItem && !is_int($maxItem)) {
0 ignored issues
show
introduced by
The condition is_int($maxItem) is always true.
Loading history...
57
            throw new \InvalidArgumentException('maxItem must be either null or an integer.');
58
        }
59
60
        $this->maxItem = $maxItem;
61
62
        return $this;
63
    }
64
65
    /**
66
     * @param TypeDoc[] $siblingList
67
     *
68
     * @return CollectionDoc
69
     */
70
    public function setSiblingList(array $siblingList) : CollectionDoc
71
    {
72
        $this->siblingList = $siblingList;
73
74
        return $this;
75
    }
76
77
    /**
78
     * @param boolean $allowExtraSibling
79
     *
80
     * @return CollectionDoc
81
     */
82
    public function setAllowExtraSibling(bool $allowExtraSibling) : CollectionDoc
83
    {
84
        $this->allowExtraSibling = $allowExtraSibling;
85
86
        return $this;
87
    }
88
89
    /**
90
     * @param boolean $allowMissingSibling
91
     *
92
     * @return CollectionDoc
93
     */
94
    public function setAllowMissingSibling(bool $allowMissingSibling) : CollectionDoc
95
    {
96
        $this->allowMissingSibling = $allowMissingSibling;
97
98
        return $this;
99
    }
100
101
    /**
102
     * @return null|int
103
     */
104
    public function getMinItem()
105
    {
106
        return $this->minItem;
107
    }
108
109
    /**
110
     * @return null|int
111
     */
112
    public function getMaxItem()
113
    {
114
        return $this->maxItem;
115
    }
116
117
    /**
118
     * @return bool
119
     */
120
    public function isAllowExtraSibling() : bool
121
    {
122
        return $this->allowExtraSibling;
123
    }
124
125
    /**
126
     * @return bool
127
     */
128
    public function isAllowMissingSibling() : bool
129
    {
130
        return $this->allowMissingSibling;
131
    }
132
133
    /**
134
     * @return TypeDoc[]
135
     */
136
    public function getSiblingList() : array
137
    {
138
        return $this->siblingList;
139
    }
140
}
141