| 1 | <?php |
||
| 13 | * @see \TraderInteractive\Filter\Ints::filter() |
||
| 14 | * |
||
| 15 | * @param mixed $value The value to be checked. |
||
| 16 | * @param bool $allowNull Indicates if the value can be null. |
||
| 17 | * @param int $minValue Indicates the minimum acceptable value. |
||
| 18 | * @param int $maxValue Indicates the maximum acceptable value. |
||
| 19 | * |
||
| 20 | * @return int|null |
||
| 21 | * |
||
| 22 | * @throws Exception |
||
| 23 | */ |
||
| 24 | public static function filter($value, bool $allowNull = false, int $minValue = null, int $maxValue = PHP_INT_MAX) |
||
| 25 | { |
||
| 26 | if ($minValue === null) { |
||
| 27 | $minValue = 0; |
||
| 28 | } elseif (is_int($minValue) && $minValue < 0) { |
||
| 29 | throw new \InvalidArgumentException("{$minValue} was not greater or equal to zero"); |
||
| 30 | } |
||
| 31 | |||
| 32 | return Ints::filter($value, $allowNull, $minValue, $maxValue); |
||
| 33 | } |
||
| 35 |