| Total Complexity | 14 |
| Total Lines | 98 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class NumberDoc extends ScalarDoc |
||
| 8 | { |
||
| 9 | /*** Validation ***/ |
||
| 10 | /** @var null|int|float */ |
||
| 11 | private $min = null; |
||
| 12 | /** @var null|int|float */ |
||
| 13 | private $max = null; |
||
| 14 | /** @var bool */ |
||
| 15 | private $inclusiveMin = true; |
||
| 16 | /** @var bool */ |
||
| 17 | private $inclusiveMax = true; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param int|float $min |
||
| 21 | * |
||
| 22 | * @return self |
||
| 23 | */ |
||
| 24 | 7 | public function setMin($min) : self |
|
| 25 | { |
||
| 26 | 7 | if (null === $min || (!is_float($min) && !is_int($min))) { |
|
| 27 | 4 | throw new \InvalidArgumentException('min must be either a float or an integer.'); |
|
| 28 | } |
||
| 29 | |||
| 30 | 3 | $this->min = $min; |
|
| 31 | |||
| 32 | 3 | return $this; |
|
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param int|float $max |
||
| 37 | * |
||
| 38 | * @return self |
||
| 39 | */ |
||
| 40 | 7 | public function setMax($max) : self |
|
| 41 | { |
||
| 42 | 7 | if (null === $max || (!is_float($max) && !is_int($max))) { |
|
| 43 | 4 | throw new \InvalidArgumentException('max must be either a float or an integer.'); |
|
| 44 | } |
||
| 45 | |||
| 46 | 3 | $this->max = $max; |
|
| 47 | |||
| 48 | 3 | return $this; |
|
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @param bool $inclusiveMax |
||
| 53 | * |
||
| 54 | * @return self |
||
| 55 | */ |
||
| 56 | 1 | public function setInclusiveMax(bool $inclusiveMax) : self |
|
| 57 | { |
||
| 58 | 1 | $this->inclusiveMax = $inclusiveMax; |
|
| 59 | |||
| 60 | 1 | return $this; |
|
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @param bool $inclusiveMin |
||
| 65 | * |
||
| 66 | * @return self |
||
| 67 | */ |
||
| 68 | 1 | public function setInclusiveMin(bool $inclusiveMin) : self |
|
| 69 | { |
||
| 70 | 1 | $this->inclusiveMin = $inclusiveMin; |
|
| 71 | |||
| 72 | 1 | return $this; |
|
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @return null|int|float |
||
| 77 | */ |
||
| 78 | 3 | public function getMin() |
|
| 79 | { |
||
| 80 | 3 | return $this->min; |
|
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @return null|int|float |
||
| 85 | */ |
||
| 86 | 3 | public function getMax() |
|
| 87 | { |
||
| 88 | 3 | return $this->max; |
|
| 89 | } |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @return bool |
||
| 93 | */ |
||
| 94 | 1 | public function isInclusiveMin() : bool |
|
| 97 | } |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @return bool |
||
| 101 | */ |
||
| 102 | 1 | public function isInclusiveMax() : bool |
|
| 105 | } |
||
| 106 | } |
||
| 107 |