We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 5 |
Paths | 3 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
34 | 304 | public function validate($input) |
|
35 | { |
||
36 | // Every integer is a factor of zero, and zero is the only integer that |
||
37 | // has zero for a factor. |
||
38 | 304 | if ($this->dividend === 0) { |
|
39 | 36 | return true; |
|
40 | } |
||
41 | |||
42 | // Factors must be integers that are not zero. |
||
43 | 268 | if (!is_numeric($input) || (int) $input != $input || $input == 0) { |
|
44 | 40 | return false; |
|
45 | } |
||
46 | |||
47 | 228 | $input = (int) abs($input); |
|
48 | 228 | $dividend = (int) abs($this->dividend); |
|
49 | |||
50 | // The dividend divided by the input must be an integer if input is a |
||
51 | // factor of the dividend. |
||
52 | 228 | return is_integer($dividend / $input); |
|
53 | } |
||
54 | } |
||
55 |