class RandomBytesGenerator
RandomBytesGenerator generates strings of random binary data using the built-in `random_bytes()` PHP function
@link http://php.net/random_bytes random_bytes()
Hierarchy
- class \Ramsey\Uuid\Generator\RandomBytesGenerator implements \Ramsey\Uuid\Generator\RandomGeneratorInterface
Expanded class hierarchy of RandomBytesGenerator
File
-
vendor/
ramsey/ uuid/ src/ Generator/ RandomBytesGenerator.php, line 26
Namespace
Ramsey\Uuid\GeneratorView source
class RandomBytesGenerator implements RandomGeneratorInterface {
/**
* @throws RandomSourceException if random_bytes() throws an exception/error
*
* @inheritDoc
*/
public function generate(int $length) : string {
try {
return random_bytes($length);
} catch (Throwable $exception) {
throw new RandomSourceException($exception->getMessage(), (int) $exception->getCode(), $exception);
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
RandomBytesGenerator::generate | public | function | @inheritDoc | Overrides RandomGeneratorInterface::generate |