| Total Complexity | 14 |
| Total Lines | 90 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| 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 NumberDoc |
||
| 23 | */ |
||
| 24 | public function setMin($min) : NumberDoc |
||
| 25 | { |
||
| 26 | if (null === $min || (!is_string($min) && !is_int($min))) { |
||
|
|
|||
| 27 | throw new \InvalidArgumentException('min must be either a float or an integer.'); |
||
| 28 | } |
||
| 29 | |||
| 30 | $this->min = $min; |
||
| 31 | |||
| 32 | return $this; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param int|float $max |
||
| 37 | * |
||
| 38 | * @return NumberDoc |
||
| 39 | */ |
||
| 40 | public function setMax($max) : NumberDoc |
||
| 41 | { |
||
| 42 | if (null === $max || (!is_string($max) && !is_int($max))) { |
||
| 43 | throw new \InvalidArgumentException('max must be either a float or an integer.'); |
||
| 44 | } |
||
| 45 | |||
| 46 | $this->max = $max; |
||
| 47 | |||
| 48 | return $this; |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @param boolean $inclusiveMax |
||
| 53 | */ |
||
| 54 | public function setInclusiveMax($inclusiveMax) |
||
| 55 | { |
||
| 56 | $this->inclusiveMax = $inclusiveMax; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @param boolean $inclusiveMin |
||
| 61 | */ |
||
| 62 | public function setInclusiveMin($inclusiveMin) |
||
| 63 | { |
||
| 64 | $this->inclusiveMin = $inclusiveMin; |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @return null|int|float |
||
| 69 | */ |
||
| 70 | public function getMin() |
||
| 71 | { |
||
| 72 | return $this->min; |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @return null|int|float |
||
| 77 | */ |
||
| 78 | public function getMax() |
||
| 79 | { |
||
| 80 | return $this->max; |
||
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @return boolean |
||
| 85 | */ |
||
| 86 | public function isInclusiveMin() |
||
| 87 | { |
||
| 88 | return $this->inclusiveMin; |
||
| 89 | } |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @return boolean |
||
| 93 | */ |
||
| 94 | public function isInclusiveMax() |
||
| 97 | } |
||
| 98 | } |
||
| 99 |