| Conditions | 4 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | 16 | private function calculateChecksum(string $amka): int |
|
| 34 | { |
||
| 35 | 16 | $sum = 0; |
|
| 36 | 16 | foreach(str_split($amka) as $index => $char) { |
|
| 37 | 16 | $tempDigit = intval($char); |
|
| 38 | 16 | if ($this->isOdd($index)) { |
|
| 39 | 16 | $tempDigit *= 2; |
|
| 40 | 16 | if ($tempDigit > 9) { |
|
| 41 | 15 | $tempDigit -= 9; |
|
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | 16 | $sum += $tempDigit; |
|
| 46 | } |
||
| 47 | |||
| 48 | 16 | return $sum; |
|
| 49 | } |
||
| 50 | |||
| 62 | } |