| Conditions | 4 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 140 | 2 | protected function isPerfectNumber($number): bool |
|
| 141 | { |
||
| 142 | 2 | $d = 0; |
|
| 143 | 2 | $max = sqrt($number); |
|
| 144 | |||
| 145 | 2 | for ($n = 2; $n <= $max; ++$n) { |
|
| 146 | 2 | if (!($number % $n)) { |
|
| 147 | 2 | $d += $n; |
|
| 148 | |||
| 149 | 2 | if ($number / $n !== $n) { |
|
| 150 | 2 | $d += $number / $n; |
|
| 151 | } |
||
| 152 | } |
||
| 153 | } |
||
| 154 | |||
| 155 | 2 | return ++$d === $number; |
|
| 156 | } |
||
| 158 |