| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 49 | 64 | public function flipBits(string $bitString): string |
|
| 50 | { |
||
| 51 | 64 | $length = strlen($bitString); |
|
| 52 | |||
| 53 | 64 | if ($length % 8 !== 0) { |
|
| 54 | 2 | throw new \Exception('Bit string length must be a multiple of 8'); |
|
| 55 | } |
||
| 56 | |||
| 57 | 62 | $newString = ''; |
|
| 58 | 62 | for ($i = $length; $i >= 0; $i -= 8) { |
|
| 59 | 62 | $newString .= substr($bitString, $i, 8); |
|
| 60 | } |
||
| 61 | |||
| 62 | 62 | return $newString; |
|
| 63 | } |
||
| 64 | } |
||
| 65 |