Cheetah
PseudoRandomStringGeneratorTrait.php
Go to the documentation of this file.
1 <?php
25 
26 trait PseudoRandomStringGeneratorTrait
27 {
35  public function validateLength($length)
36  {
37  if (!is_int($length)) {
38  throw new \InvalidArgumentException('getPseudoRandomString() expects an integer for the string length');
39  }
40 
41  if ($length < 1) {
42  throw new \InvalidArgumentException('getPseudoRandomString() expects a length greater than 1');
43  }
44  }
45 
54  public function binToHex($binaryData, $length)
55  {
56  return \substr(\bin2hex($binaryData), 0, $length);
57  }
58 }
php
Facebook\PseudoRandomString
Definition: McryptPseudoRandomStringGenerator.php:24