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