aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2018-08-28 12:00:23 +0200
committerMario Vavti <mario@mariovavti.com>2018-08-28 12:00:23 +0200
commitc0c827d3ad2c8364d35fff5546ab40ea76bbbbd9 (patch)
tree34bb14bb6046ce98bd6ad759b9c57624b2be7d34 /vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php
parent6a2bbed73dfb34975c4525c34c03f20c6945dedc (diff)
downloadvolse-hubzilla-c0c827d3ad2c8364d35fff5546ab40ea76bbbbd9.tar.gz
volse-hubzilla-c0c827d3ad2c8364d35fff5546ab40ea76bbbbd9.tar.bz2
volse-hubzilla-c0c827d3ad2c8364d35fff5546ab40ea76bbbbd9.zip
update composer libs and add ramsey/uuid
Diffstat (limited to 'vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php')
-rw-r--r--vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php b/vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php
new file mode 100644
index 000000000..d23512256
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * This file is part of the ramsey/uuid library
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ *
+ * @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
+ */
+
+namespace Ramsey\Uuid\Converter\Number;
+
+use Moontoast\Math\BigNumber;
+use Ramsey\Uuid\Converter\NumberConverterInterface;
+
+/**
+ * BigNumberConverter converts UUIDs from hexadecimal characters into
+ * moontoast/math `BigNumber` representations of integers and vice versa
+ */
+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
+ */
+ public function fromHex($hex)
+ {
+ $number = BigNumber::convertToBase10($hex, 16);
+
+ return new BigNumber($number);
+ }
+
+ /**
+ * 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
+ */
+ public function toHex($integer)
+ {
+ if (!$integer instanceof BigNumber) {
+ $integer = new BigNumber($integer);
+ }
+
+ return BigNumber::convertFromBase10($integer, 16);
+ }
+}