| Conditions | 4 |
| Paths | 4 |
| Total Lines | 20 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 27 | public function getBytes($count) |
|
| 16 | { |
||
| 17 | 27 | $count = (int) $count; |
|
| 18 | |||
| 19 | 27 | if ($count === 0) { |
|
| 20 | 3 | return ''; |
|
| 21 | } |
||
| 22 | |||
| 23 | 24 | $bytes = $this->readBytes($count); |
|
| 24 | |||
| 25 | 24 | if (!is_string($bytes)) { |
|
| 26 | 3 | throw new GeneratorException('The random byte generator did not return a string'); |
|
| 27 | } |
||
| 28 | |||
| 29 | 21 | if (strlen($bytes) !== $count) { |
|
| 30 | 3 | throw new GeneratorException('The random byte generator returned an invalid number of bytes'); |
|
| 31 | } |
||
| 32 | |||
| 33 | 18 | return $bytes; |
|
| 34 | } |
||
| 35 | |||
| 44 |