| Conditions | 5 |
| Paths | 4 |
| Total Lines | 21 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | public function passes($attribute, $value): bool |
||
| 13 | { |
||
| 14 | if (! is_numeric($value)) { |
||
| 15 | return false; |
||
| 16 | } |
||
| 17 | |||
| 18 | $number = strval($value); |
||
| 19 | $number = explode('.', $number); |
||
| 20 | |||
| 21 | // Check if there is a decimal part and it's not zero |
||
| 22 | if (isset($number[1]) && $number[1] != 0) { |
||
| 23 | return false; |
||
| 24 | } |
||
| 25 | |||
| 26 | $number = $number[0]; |
||
| 27 | |||
| 28 | if (extension_loaded('gmp')) { |
||
| 29 | return gmp_cmp(gmp_mod($number, '2'), '0') === 0; |
||
| 30 | } |
||
| 31 | |||
| 32 | return $number % 2 === 0; |
||
| 33 | } |
||
| 43 |