aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php')
-rw-r--r--vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php51
1 files changed, 27 insertions, 24 deletions
diff --git a/vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php b/vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php
index d23512256..fef63fd00 100644
--- a/vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php
+++ b/vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php
@@ -1,4 +1,5 @@
<?php
+
/**
* This file is part of the ramsey/uuid library
*
@@ -7,48 +8,50 @@
*
* @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\Converter\Number;
-use Moontoast\Math\BigNumber;
use Ramsey\Uuid\Converter\NumberConverterInterface;
+use Ramsey\Uuid\Math\BrickMathCalculator;
/**
- * BigNumberConverter converts UUIDs from hexadecimal characters into
- * moontoast/math `BigNumber` representations of integers and vice versa
+ * Previously used to integrate moontoast/math as a bignum arithmetic library,
+ * BigNumberConverter is deprecated in favor of GenericNumberConverter
+ *
+ * @deprecated Transition to {@see GenericNumberConverter}.
+ *
+ * @psalm-immutable
*/
class BigNumberConverter implements NumberConverterInterface
{
/**
- * Converts a hexadecimal number into a `Moontoast\Math\BigNumber` representation
- *
- * @param string $hex The hexadecimal string representation to convert
- * @return BigNumber
+ * @var NumberConverterInterface
*/
- public function fromHex($hex)
- {
- $number = BigNumber::convertToBase10($hex, 16);
+ private $converter;
- return new BigNumber($number);
+ public function __construct()
+ {
+ $this->converter = new GenericNumberConverter(new BrickMathCalculator());
}
/**
- * Converts an integer or `Moontoast\Math\BigNumber` integer representation
- * into a hexadecimal string representation
- *
- * @param int|string|BigNumber $integer An integer or `Moontoast\Math\BigNumber`
- * @return string Hexadecimal string
+ * @inheritDoc
+ * @psalm-pure
*/
- public function toHex($integer)
+ public function fromHex(string $hex): string
{
- if (!$integer instanceof BigNumber) {
- $integer = new BigNumber($integer);
- }
+ return $this->converter->fromHex($hex);
+ }
- return BigNumber::convertFromBase10($integer, 16);
+ /**
+ * @inheritDoc
+ * @psalm-pure
+ */
+ public function toHex(string $number): string
+ {
+ return $this->converter->toHex($number);
}
}