From f4bb7bcbff3770387c2fecfa91ce4a60b916a474 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 27 Nov 2020 08:04:00 +0000 Subject: update composer libs --- .../uuid/src/Generator/RandomBytesGenerator.php | 33 +++++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php') diff --git a/vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php b/vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php index cc3d37989..e6e9a199b 100644 --- a/vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php +++ b/vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php @@ -1,4 +1,5 @@ * @license http://opensource.org/licenses/MIT MIT - * @link https://benramsey.com/projects/ramsey-uuid/ Documentation - * @link https://packagist.org/packages/ramsey/uuid Packagist - * @link https://github.com/ramsey/uuid GitHub */ +declare(strict_types=1); + namespace Ramsey\Uuid\Generator; -use Exception; +use Ramsey\Uuid\Exception\RandomSourceException; /** - * RandomBytesGenerator provides functionality to generate strings of random - * binary data using `random_bytes()` function in PHP 7+ or paragonie/random_compat + * RandomBytesGenerator generates strings of random binary data using the + * built-in `random_bytes()` PHP function * - * @link http://php.net/random_bytes - * @link https://github.com/paragonie/random_compat + * @link http://php.net/random_bytes random_bytes() */ class RandomBytesGenerator implements RandomGeneratorInterface { /** - * Generates a string of random binary data of the specified length + * @throws RandomSourceException if random_bytes() throws an exception/error * - * @param integer $length The number of bytes of random binary data to generate - * @return string A binary string - * @throws Exception if it was not possible to gather sufficient entropy + * @inheritDoc */ - public function generate($length) + public function generate(int $length): string { - return random_bytes($length); + try { + return random_bytes($length); + } catch (\Throwable $exception) { + throw new RandomSourceException( + $exception->getMessage(), + (int) $exception->getCode(), + $exception + ); + } } } -- cgit v1.2.3