Conditions | 7 |
Paths | 5 |
Total Lines | 29 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 7 |
Changes | 0 |
1 | <?php |
||
42 | 28 | protected function validation($input, &$value): bool |
|
43 | { |
||
44 | 28 | if (\is_bool($input)) { |
|
45 | 1 | return false; |
|
46 | } |
||
47 | |||
48 | 27 | if ($this->strict && \is_int($input) === false) { |
|
49 | 1 | return false; |
|
50 | } |
||
51 | |||
52 | $options = [ |
||
53 | 'options' => [ |
||
54 | 26 | 'min_range' => PHP_INT_MIN, |
|
55 | 26 | 'max_range' => PHP_INT_MAX, |
|
56 | ], |
||
57 | ]; |
||
58 | |||
59 | 26 | $returned = filter_var($input, FILTER_VALIDATE_INT, $options); |
|
60 | 26 | if ($returned === false) { |
|
61 | 8 | return false; |
|
62 | } |
||
63 | |||
64 | 18 | if ($returned < $this->min || $returned > $this->max) { |
|
65 | 4 | return false; |
|
66 | } |
||
67 | |||
68 | 15 | $value = $returned; |
|
69 | |||
70 | 15 | return true; |
|
71 | } |
||
73 |