aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-11-27 08:04:00 +0000
committerMario <mario@mariovavti.com>2020-11-27 08:04:00 +0000
commitf4bb7bcbff3770387c2fecfa91ce4a60b916a474 (patch)
treeea007e664d435f1f3d63c87bfe1600484d2bd46c /vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php
parent07e5b8295ea9d342f66d8119d88bd58124b548e6 (diff)
downloadvolse-hubzilla-f4bb7bcbff3770387c2fecfa91ce4a60b916a474.tar.gz
volse-hubzilla-f4bb7bcbff3770387c2fecfa91ce4a60b916a474.tar.bz2
volse-hubzilla-f4bb7bcbff3770387c2fecfa91ce4a60b916a474.zip
update composer libs
Diffstat (limited to 'vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php')
-rw-r--r--vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php33
1 files changed, 19 insertions, 14 deletions
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 @@
<?php
+
/**
* This file is part of the ramsey/uuid library
*
@@ -7,33 +8,37 @@
*
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
* @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
+ );
+ }
}
}