| Conditions | 4 |
| Paths | 5 |
| Total Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 40 | protected function calculateSum(string $number): int |
||
| 41 | { |
||
| 42 | $weight = 2; |
||
| 43 | $sum = 0; |
||
| 44 | |||
| 45 | for ($pos=strlen($number)-1; $pos>=0; $pos--) { |
||
| 46 | $tmp = $number[$pos] * $weight; |
||
| 47 | $sum += ($tmp > 9) ? (1 + ($tmp % 10)) : $tmp; |
||
| 48 | $weight = ($weight == 2) ? 1 : 2; |
||
| 49 | } |
||
| 50 | |||
| 51 | return $sum; |
||
| 52 | } |
||
| 53 | } |
||
| 54 |