| Conditions | 4 |
| Paths | 4 |
| Total Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 2 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 15 | 3 | public function generateUniqueIdentifier($length = 40) |
|
| 16 | { |
||
| 17 | try { |
||
| 18 | 3 | return bin2hex(random_bytes($length)); |
|
| 19 | // @codeCoverageIgnoreStart |
||
| 20 | } catch (TypeError $e) { |
||
| 21 | throw OAuthServerException::serverError('An unexpected error has occurred', $e); |
||
| 22 | } catch (Error $e) { |
||
| 23 | throw OAuthServerException::serverError('An unexpected error has occurred', $e); |
||
| 24 | } catch (Exception $e) { |
||
| 25 | // If you get this message, the CSPRNG failed hard. |
||
| 26 | throw OAuthServerException::serverError('Could not generate a random string', $e); |
||
| 27 | } |
||
| 28 | // @codeCoverageIgnoreEnd |
||
| 29 | } |
||
| 30 | } |
||
| 31 |