| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | public function getPseudoRandomString($length) |
||
| 30 | { |
||
| 31 | $this->validateLength($length); |
||
| 32 | |||
| 33 | $wasCryptographicallyStrong = false; |
||
| 34 | $binaryString = openssl_random_pseudo_bytes($length, $wasCryptographicallyStrong); |
||
| 35 | |||
| 36 | if ($binaryString === false) { |
||
| 37 | throw new InstagramSDKException(static::ERROR_MESSAGE . 'openssl_random_pseudo_bytes() returned an unknown error.'); |
||
| 38 | } |
||
| 39 | |||
| 40 | if ($wasCryptographicallyStrong !== true) { |
||
| 41 | throw new InstagramSDKException(static::ERROR_MESSAGE . 'openssl_random_pseudo_bytes() returned a pseudo-random string but it was not cryptographically secure and cannot be used.'); |
||
| 42 | } |
||
| 43 | |||
| 44 | return $this->binToHex($binaryString, $length); |
||
| 45 | } |
||
| 47 |