| Conditions | 5 |
| Paths | 5 |
| Total Lines | 27 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | 3 | public function __invoke($input) |
|
| 23 | { |
||
| 24 | 3 | if (! is_int($input)) { |
|
| 25 | 1 | return false; |
|
| 26 | } |
||
| 27 | |||
| 28 | 2 | $n = abs($input); |
|
| 29 | |||
| 30 | 2 | if ($n < 2) { |
|
| 31 | 2 | return false; |
|
| 32 | } |
||
| 33 | |||
| 34 | 2 | $sqrt = sqrt($n); |
|
| 35 | |||
| 36 | 2 | $i = 2; |
|
| 37 | |||
| 38 | 2 | while ($i <= $sqrt) { |
|
| 39 | |||
| 40 | 2 | if ($n % $i === 0) { |
|
| 41 | 2 | return false; |
|
| 42 | } |
||
| 43 | |||
| 44 | 2 | $i++; |
|
| 45 | } |
||
| 46 | |||
| 47 | 2 | return true; |
|
| 48 | } |
||
| 49 | } |
||
| 50 |