| Total Complexity | 4 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | trait PseudoRandomStringGeneratorTrait |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Validates the length argument of a random string. |
||
| 9 | * |
||
| 10 | * @param int $length The length to validate. |
||
| 11 | * |
||
| 12 | * @throws \InvalidArgumentException |
||
| 13 | */ |
||
| 14 | public function validateLength($length) |
||
| 15 | { |
||
| 16 | if (!is_int($length)) { |
||
|
|
|||
| 17 | throw new \InvalidArgumentException('getPseudoRandomString() expects an integer for the string length'); |
||
| 18 | } |
||
| 19 | |||
| 20 | if ($length < 1) { |
||
| 21 | throw new \InvalidArgumentException('getPseudoRandomString() expects a length greater than 1'); |
||
| 22 | } |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Converts binary data to hexadecimal of arbitrary length. |
||
| 27 | * |
||
| 28 | * @param string $binaryData The binary data to convert to hex. |
||
| 29 | * @param int $length The length of the string to return. |
||
| 30 | * |
||
| 31 | * @return string |
||
| 32 | */ |
||
| 33 | public function binToHex($binaryData, $length) |
||
| 36 | } |
||
| 37 | } |
||
| 38 |