summaryrefslogtreecommitdiff
path: root/vendor/ramsey/uuid/src
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ramsey/uuid/src')
-rw-r--r--vendor/ramsey/uuid/src/BinaryUtils.php43
-rw-r--r--vendor/ramsey/uuid/src/Builder/DefaultUuidBuilder.php54
-rw-r--r--vendor/ramsey/uuid/src/Builder/DegradedUuidBuilder.php53
-rw-r--r--vendor/ramsey/uuid/src/Builder/UuidBuilderInterface.php34
-rw-r--r--vendor/ramsey/uuid/src/Codec/CodecInterface.php55
-rw-r--r--vendor/ramsey/uuid/src/Codec/GuidStringCodec.php100
-rw-r--r--vendor/ramsey/uuid/src/Codec/OrderedTimeCodec.php67
-rw-r--r--vendor/ramsey/uuid/src/Codec/StringCodec.php167
-rw-r--r--vendor/ramsey/uuid/src/Codec/TimestampFirstCombCodec.php105
-rw-r--r--vendor/ramsey/uuid/src/Codec/TimestampLastCombCodec.php23
-rw-r--r--vendor/ramsey/uuid/src/Console/Application.php31
-rw-r--r--vendor/ramsey/uuid/src/Console/Command/DecodeCommand.php143
-rw-r--r--vendor/ramsey/uuid/src/Console/Command/GenerateCommand.php167
-rw-r--r--vendor/ramsey/uuid/src/Console/Exception.php19
-rw-r--r--vendor/ramsey/uuid/src/Console/Util/ErrorHandler.php49
-rw-r--r--vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php54
-rw-r--r--vendor/ramsey/uuid/src/Converter/Number/DegradedNumberConverter.php58
-rw-r--r--vendor/ramsey/uuid/src/Converter/NumberConverterInterface.php44
-rw-r--r--vendor/ramsey/uuid/src/Converter/Time/BigNumberTimeConverter.php58
-rw-r--r--vendor/ramsey/uuid/src/Converter/Time/DegradedTimeConverter.php42
-rw-r--r--vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php47
-rw-r--r--vendor/ramsey/uuid/src/Converter/TimeConverterInterface.php33
-rw-r--r--vendor/ramsey/uuid/src/DegradedUuid.php111
-rw-r--r--vendor/ramsey/uuid/src/Doctrine/UuidType.php108
-rw-r--r--vendor/ramsey/uuid/src/Exception/InvalidUuidStringException.php22
-rw-r--r--vendor/ramsey/uuid/src/Exception/UnsatisfiedDependencyException.php9
-rw-r--r--vendor/ramsey/uuid/src/Exception/UnsupportedOperationException.php9
-rw-r--r--vendor/ramsey/uuid/src/FeatureSet.php333
-rw-r--r--vendor/ramsey/uuid/src/Generator/CombGenerator.php85
-rw-r--r--vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php132
-rw-r--r--vendor/ramsey/uuid/src/Generator/MtRandGenerator.php41
-rw-r--r--vendor/ramsey/uuid/src/Generator/OpenSslGenerator.php38
-rw-r--r--vendor/ramsey/uuid/src/Generator/PeclUuidRandomGenerator.php37
-rw-r--r--vendor/ramsey/uuid/src/Generator/PeclUuidTimeGenerator.php38
-rw-r--r--vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php36
-rw-r--r--vendor/ramsey/uuid/src/Generator/RandomGeneratorFactory.php31
-rw-r--r--vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php30
-rw-r--r--vendor/ramsey/uuid/src/Generator/RandomLibAdapter.php62
-rw-r--r--vendor/ramsey/uuid/src/Generator/SodiumRandomGenerator.php36
-rw-r--r--vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php72
-rw-r--r--vendor/ramsey/uuid/src/Generator/TimeGeneratorInterface.php35
-rw-r--r--vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php57
-rw-r--r--vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php36
-rw-r--r--vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php76
-rw-r--r--vendor/ramsey/uuid/src/Provider/NodeProviderInterface.php29
-rw-r--r--vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php76
-rw-r--r--vendor/ramsey/uuid/src/Provider/Time/SystemTimeProvider.php33
-rw-r--r--vendor/ramsey/uuid/src/Provider/TimeProviderInterface.php29
-rw-r--r--vendor/ramsey/uuid/src/Uuid.php901
-rw-r--r--vendor/ramsey/uuid/src/UuidFactory.php292
-rw-r--r--vendor/ramsey/uuid/src/UuidFactoryInterface.php89
-rw-r--r--vendor/ramsey/uuid/src/UuidInterface.php267
52 files changed, 3338 insertions, 1258 deletions
diff --git a/vendor/ramsey/uuid/src/BinaryUtils.php b/vendor/ramsey/uuid/src/BinaryUtils.php
new file mode 100644
index 0000000000..f04a9d9c18
--- /dev/null
+++ b/vendor/ramsey/uuid/src/BinaryUtils.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace Ramsey\Uuid;
+
+/**
+ * Provides binary math utilities
+ */
+class BinaryUtils
+{
+ /**
+ * Applies the RFC 4122 variant field to the `clock_seq_hi_and_reserved` field
+ *
+ * @param $clockSeqHi
+ * @return int The high field of the clock sequence multiplexed with the variant
+ * @link http://tools.ietf.org/html/rfc4122#section-4.1.1
+ */
+ public static function applyVariant($clockSeqHi)
+ {
+ // Set the variant to RFC 4122
+ $clockSeqHi = $clockSeqHi & 0x3f;
+ $clockSeqHi &= ~(0xc0);
+ $clockSeqHi |= 0x80;
+
+ return $clockSeqHi;
+ }
+
+ /**
+ * Applies the RFC 4122 version number to the `time_hi_and_version` field
+ *
+ * @param string $timeHi
+ * @param integer $version
+ * @return int The high field of the timestamp multiplexed with the version number
+ * @link http://tools.ietf.org/html/rfc4122#section-4.1.3
+ */
+ public static function applyVersion($timeHi, $version)
+ {
+ $timeHi = hexdec($timeHi) & 0x0fff;
+ $timeHi &= ~(0xf000);
+ $timeHi |= $version << 12;
+
+ return $timeHi;
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Builder/DefaultUuidBuilder.php b/vendor/ramsey/uuid/src/Builder/DefaultUuidBuilder.php
new file mode 100644
index 0000000000..20656acdfd
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Builder/DefaultUuidBuilder.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\Builder;
+
+use Ramsey\Uuid\Codec\CodecInterface;
+use Ramsey\Uuid\Converter\NumberConverterInterface;
+use Ramsey\Uuid\Uuid;
+
+/**
+ * DefaultUuidBuilder is the default UUID builder for ramsey/uuid; it builds
+ * instances of Uuid objects
+ */
+class DefaultUuidBuilder implements UuidBuilderInterface
+{
+ /**
+ * @var NumberConverterInterface
+ */
+ private $converter;
+
+ /**
+ * Constructs the DefaultUuidBuilder
+ *
+ * @param NumberConverterInterface $converter The number converter to use when constructing the Uuid
+ */
+ public function __construct(NumberConverterInterface $converter)
+ {
+ $this->converter = $converter;
+ }
+
+ /**
+ * Builds a Uuid
+ *
+ * @param CodecInterface $codec The codec to use for building this Uuid
+ * @param array $fields An array of fields from which to construct the Uuid;
+ * see {@see \Ramsey\Uuid\UuidInterface::getFieldsHex()} for array structure.
+ * @return Uuid
+ */
+ public function build(CodecInterface $codec, array $fields)
+ {
+ return new Uuid($fields, $this->converter, $codec);
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Builder/DegradedUuidBuilder.php b/vendor/ramsey/uuid/src/Builder/DegradedUuidBuilder.php
new file mode 100644
index 0000000000..7edb6deb7c
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Builder/DegradedUuidBuilder.php
@@ -0,0 +1,53 @@
+<?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\Builder;
+
+use Ramsey\Uuid\Codec\CodecInterface;
+use Ramsey\Uuid\Converter\NumberConverterInterface;
+use Ramsey\Uuid\DegradedUuid;
+
+/**
+ * DegradedUuidBuilder builds instances of DegradedUuid
+ */
+class DegradedUuidBuilder implements UuidBuilderInterface
+{
+ /**
+ * @var NumberConverterInterface
+ */
+ private $converter;
+
+ /**
+ * Constructs the DegradedUuidBuilder
+ *
+ * @param NumberConverterInterface $converter The number converter to use when constructing the DegradedUuid
+ */
+ public function __construct(NumberConverterInterface $converter)
+ {
+ $this->converter = $converter;
+ }
+
+ /**
+ * Builds a DegradedUuid
+ *
+ * @param CodecInterface $codec The codec to use for building this DegradedUuid
+ * @param array $fields An array of fields from which to construct the DegradedUuid;
+ * see {@see \Ramsey\Uuid\UuidInterface::getFieldsHex()} for array structure.
+ * @return DegradedUuid
+ */
+ public function build(CodecInterface $codec, array $fields)
+ {
+ return new DegradedUuid($fields, $this->converter, $codec);
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Builder/UuidBuilderInterface.php b/vendor/ramsey/uuid/src/Builder/UuidBuilderInterface.php
new file mode 100644
index 0000000000..e4e9901091
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Builder/UuidBuilderInterface.php
@@ -0,0 +1,34 @@
+<?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\Builder;
+
+use Ramsey\Uuid\Codec\CodecInterface;
+use Ramsey\Uuid\UuidInterface;
+
+/**
+ * UuidBuilderInterface builds instances UuidInterface
+ */
+interface UuidBuilderInterface
+{
+ /**
+ * Builds an instance of a UuidInterface
+ *
+ * @param CodecInterface $codec The codec to use for building this UuidInterface instance
+ * @param array $fields An array of fields from which to construct a UuidInterface instance;
+ * see {@see \Ramsey\Uuid\UuidInterface::getFieldsHex()} for array structure.
+ * @return UuidInterface
+ */
+ public function build(CodecInterface $codec, array $fields);
+}
diff --git a/vendor/ramsey/uuid/src/Codec/CodecInterface.php b/vendor/ramsey/uuid/src/Codec/CodecInterface.php
new file mode 100644
index 0000000000..f0dde95067
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Codec/CodecInterface.php
@@ -0,0 +1,55 @@
+<?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\Codec;
+
+use Ramsey\Uuid\UuidInterface;
+
+/**
+ * CodecInterface represents a UUID coder-decoder
+ */
+interface CodecInterface
+{
+ /**
+ * Encodes a UuidInterface as a string representation of a UUID
+ *
+ * @param UuidInterface $uuid
+ * @return string Hexadecimal string representation of a UUID
+ */
+ public function encode(UuidInterface $uuid);
+
+ /**
+ * Encodes a UuidInterface as a binary representation of a UUID
+ *
+ * @param UuidInterface $uuid
+ * @return string Binary string representation of a UUID
+ */
+ public function encodeBinary(UuidInterface $uuid);
+
+ /**
+ * Decodes a string representation of a UUID into a UuidInterface object instance
+ *
+ * @param string $encodedUuid
+ * @return UuidInterface
+ */
+ public function decode($encodedUuid);
+
+ /**
+ * Decodes a binary representation of a UUID into a UuidInterface object instance
+ *
+ * @param string $bytes
+ * @return UuidInterface
+ */
+ public function decodeBytes($bytes);
+}
diff --git a/vendor/ramsey/uuid/src/Codec/GuidStringCodec.php b/vendor/ramsey/uuid/src/Codec/GuidStringCodec.php
new file mode 100644
index 0000000000..380d94efea
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Codec/GuidStringCodec.php
@@ -0,0 +1,100 @@
+<?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\Codec;
+
+use Ramsey\Uuid\UuidInterface;
+
+/**
+ * GuidStringCodec encodes and decodes globally unique identifiers (GUID)
+ *
+ * @link https://en.wikipedia.org/wiki/Globally_unique_identifier
+ */
+class GuidStringCodec extends StringCodec
+{
+ /**
+ * Encodes a UuidInterface as a string representation of a GUID
+ *
+ * @param UuidInterface $uuid
+ * @return string Hexadecimal string representation of a GUID
+ */
+ public function encode(UuidInterface $uuid)
+ {
+ $components = array_values($uuid->getFieldsHex());
+
+ // Swap byte-order on the first three fields
+ $this->swapFields($components);
+
+ return vsprintf(
+ '%08s-%04s-%04s-%02s%02s-%012s',
+ $components
+ );
+ }
+
+ /**
+ * Encodes a UuidInterface as a binary representation of a GUID
+ *
+ * @param UuidInterface $uuid
+ * @return string Binary string representation of a GUID
+ */
+ public function encodeBinary(UuidInterface $uuid)
+ {
+ $components = array_values($uuid->getFieldsHex());
+
+ return hex2bin(implode('', $components));
+ }
+
+ /**
+ * Decodes a string representation of a GUID into a UuidInterface object instance
+ *
+ * @param string $encodedUuid
+ * @return UuidInterface
+ */
+ public function decode($encodedUuid)
+ {
+ $components = $this->extractComponents($encodedUuid);
+
+ $this->swapFields($components);
+
+ return $this->getBuilder()->build($this, $this->getFields($components));
+ }
+
+ /**
+ * Decodes a binary representation of a GUID into a UuidInterface object instance
+ *
+ * @param string $bytes
+ * @return UuidInterface
+ */
+ public function decodeBytes($bytes)
+ {
+ // Specifically call parent::decode to preserve correct byte order
+ return parent::decode(bin2hex($bytes));
+ }
+
+ /**
+ * Swaps fields to support GUID byte order
+ *
+ * @param array $components An array of UUID components (the UUID exploded on its dashes)
+ * @return void
+ */
+ protected function swapFields(array &$components)
+ {
+ $hex = unpack('H*', pack('L', hexdec($components[0])));
+ $components[0] = $hex[1];
+ $hex = unpack('H*', pack('S', hexdec($components[1])));
+ $components[1] = $hex[1];
+ $hex = unpack('H*', pack('S', hexdec($components[2])));
+ $components[2] = $hex[1];
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Codec/OrderedTimeCodec.php b/vendor/ramsey/uuid/src/Codec/OrderedTimeCodec.php
new file mode 100644
index 0000000000..cbbb75ea1c
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Codec/OrderedTimeCodec.php
@@ -0,0 +1,67 @@
+<?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\Codec;
+
+use InvalidArgumentException;
+use Ramsey\Uuid\UuidInterface;
+
+/**
+ * OrderedTimeCodec optimizes the bytes to increment UUIDs when time goes by, to improve database INSERTs.
+ * The string value will be unchanged from StringCodec. Only works for UUID type 1.
+ */
+class OrderedTimeCodec extends StringCodec
+{
+
+ /**
+ * Encodes a UuidInterface as an optimized binary representation of a UUID
+ *
+ * @param UuidInterface $uuid
+ * @return string Binary string representation of a UUID
+ */
+ public function encodeBinary(UuidInterface $uuid)
+ {
+ $fields = $uuid->getFieldsHex();
+
+ $optimized = [
+ $fields['time_hi_and_version'],
+ $fields['time_mid'],
+ $fields['time_low'],
+ $fields['clock_seq_hi_and_reserved'],
+ $fields['clock_seq_low'],
+ $fields['node'],
+ ];
+
+ return hex2bin(implode('', $optimized));
+ }
+
+ /**
+ * Decodes an optimized binary representation of a UUID into a UuidInterface object instance
+ *
+ * @param string $bytes
+ * @return UuidInterface
+ */
+ public function decodeBytes($bytes)
+ {
+ if (strlen($bytes) !== 16) {
+ throw new InvalidArgumentException('$bytes string should contain 16 characters.');
+ }
+
+ $hex = unpack('H*', $bytes)[1];
+
+ // Rearrange the fields to their original order
+ $hex = substr($hex, 8, 4) . substr($hex, 12, 4) . substr($hex, 4, 4) . substr($hex, 0, 4) . substr($hex, 16);
+
+ return $this->decode($hex);
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Codec/StringCodec.php b/vendor/ramsey/uuid/src/Codec/StringCodec.php
new file mode 100644
index 0000000000..46181964dd
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Codec/StringCodec.php
@@ -0,0 +1,167 @@
+<?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\Codec;
+
+use InvalidArgumentException;
+use Ramsey\Uuid\Builder\UuidBuilderInterface;
+use Ramsey\Uuid\Exception\InvalidUuidStringException;
+use Ramsey\Uuid\Uuid;
+use Ramsey\Uuid\UuidInterface;
+
+/**
+ * StringCodec encodes and decodes RFC 4122 UUIDs
+ *
+ * @link http://tools.ietf.org/html/rfc4122
+ */
+class StringCodec implements CodecInterface
+{
+ /**
+ * @var UuidBuilderInterface
+ */
+ private $builder;
+
+ /**
+ * Constructs a StringCodec for use encoding and decoding UUIDs
+ *
+ * @param UuidBuilderInterface $builder The UUID builder to use when encoding UUIDs
+ */
+ public function __construct(UuidBuilderInterface $builder)
+ {
+ $this->builder = $builder;
+ }
+
+ /**
+ * Encodes a UuidInterface as a string representation of a UUID
+ *
+ * @param UuidInterface $uuid
+ * @return string Hexadecimal string representation of a UUID
+ */
+ public function encode(UuidInterface $uuid)
+ {
+ $fields = array_values($uuid->getFieldsHex());
+
+ return vsprintf(
+ '%08s-%04s-%04s-%02s%02s-%012s',
+ $fields
+ );
+ }
+
+ /**
+ * Encodes a UuidInterface as a binary representation of a UUID
+ *
+ * @param UuidInterface $uuid
+ * @return string Binary string representation of a UUID
+ */
+ public function encodeBinary(UuidInterface $uuid)
+ {
+ return hex2bin($uuid->getHex());
+ }
+
+ /**
+ * Decodes a string representation of a UUID into a UuidInterface object instance
+ *
+ * @param string $encodedUuid
+ * @return UuidInterface
+ */
+ public function decode($encodedUuid)
+ {
+ $components = $this->extractComponents($encodedUuid);
+ $fields = $this->getFields($components);
+
+ return $this->builder->build($this, $fields);
+ }
+
+ /**
+ * Decodes a binary representation of a UUID into a UuidInterface object instance
+ *
+ * @param string $bytes
+ * @return UuidInterface
+ */
+ public function decodeBytes($bytes)
+ {
+ if (strlen($bytes) !== 16) {
+ throw new InvalidArgumentException('$bytes string should contain 16 characters.');
+ }
+
+ $hexUuid = unpack('H*', $bytes);
+
+ return $this->decode($hexUuid[1]);
+ }
+
+ /**
+ * Returns the UUID builder
+ *
+ * @return UuidBuilderInterface
+ */
+ protected function getBuilder()
+ {
+ return $this->builder;
+ }
+
+ /**
+ * Returns an array of UUID components (the UUID exploded on its dashes)
+ *
+ * @param string $encodedUuid
+ * @return array
+ */
+ protected function extractComponents($encodedUuid)
+ {
+ $nameParsed = str_replace(array(
+ 'urn:',
+ 'uuid:',
+ '{',
+ '}',
+ '-'
+ ), '', $encodedUuid);
+
+ // We have stripped out the dashes and are breaking up the string using
+ // substr(). In this way, we can accept a full hex value that doesn't
+ // contain dashes.
+ $components = array(
+ substr($nameParsed, 0, 8),
+ substr($nameParsed, 8, 4),
+ substr($nameParsed, 12, 4),
+ substr($nameParsed, 16, 4),
+ substr($nameParsed, 20)
+ );
+
+ $nameParsed = implode('-', $components);
+
+ if (!Uuid::isValid($nameParsed)) {
+ throw new InvalidUuidStringException('Invalid UUID string: ' . $encodedUuid);
+ }
+
+ return $components;
+ }
+
+ /**
+ * Returns the fields that make up this UUID
+ *
+ * @see \Ramsey\Uuid\UuidInterface::getFieldsHex()
+ * @param array $components
+ * @return array
+ */
+ protected function getFields(array $components)
+ {
+ return array(
+ 'time_low' => str_pad($components[0], 8, '0', STR_PAD_LEFT),
+ 'time_mid' => str_pad($components[1], 4, '0', STR_PAD_LEFT),
+ 'time_hi_and_version' => str_pad($components[2], 4, '0', STR_PAD_LEFT),
+ 'clock_seq_hi_and_reserved' => str_pad(substr($components[3], 0, 2), 2, '0', STR_PAD_LEFT),
+ 'clock_seq_low' => str_pad(substr($components[3], 2), 2, '0', STR_PAD_LEFT),
+ 'node' => str_pad($components[4], 12, '0', STR_PAD_LEFT)
+ );
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Codec/TimestampFirstCombCodec.php b/vendor/ramsey/uuid/src/Codec/TimestampFirstCombCodec.php
new file mode 100644
index 0000000000..c4434384fa
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Codec/TimestampFirstCombCodec.php
@@ -0,0 +1,105 @@
+<?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\Codec;
+
+use Ramsey\Uuid\UuidInterface;
+
+/**
+ * TimestampLastCombCodec encodes and decodes COMB UUIDs which have the timestamp as the first 48 bits.
+ * To be used with MySQL, PostgreSQL, Oracle.
+ */
+class TimestampFirstCombCodec extends StringCodec
+{
+ /**
+ * Encodes a UuidInterface as a string representation of a timestamp first COMB UUID
+ *
+ * @param UuidInterface $uuid
+ *
+ * @return string Hexadecimal string representation of a GUID
+ */
+ public function encode(UuidInterface $uuid)
+ {
+ $sixPieceComponents = array_values($uuid->getFieldsHex());
+
+ $this->swapTimestampAndRandomBits($sixPieceComponents);
+
+ return vsprintf(
+ '%08s-%04s-%04s-%02s%02s-%012s',
+ $sixPieceComponents
+ );
+ }
+
+ /**
+ * Encodes a UuidInterface as a binary representation of timestamp first COMB UUID
+ *
+ * @param UuidInterface $uuid
+ *
+ * @return string Binary string representation of timestamp first COMB UUID
+ */
+ public function encodeBinary(UuidInterface $uuid)
+ {
+ $stringEncoding = $this->encode($uuid);
+
+ return hex2bin(str_replace('-', '', $stringEncoding));
+ }
+
+ /**
+ * Decodes a string representation of timestamp first COMB UUID into a UuidInterface object instance
+ *
+ * @param string $encodedUuid
+ *
+ * @return UuidInterface
+ */
+ public function decode($encodedUuid)
+ {
+ $fivePieceComponents = $this->extractComponents($encodedUuid);
+
+ $this->swapTimestampAndRandomBits($fivePieceComponents);
+
+ return $this->getBuilder()->build($this, $this->getFields($fivePieceComponents));
+ }
+
+ /**
+ * Decodes a binary representation of timestamp first COMB UUID into a UuidInterface object instance
+ *
+ * @param string $bytes
+ *
+ * @return UuidInterface
+ */
+ public function decodeBytes($bytes)
+ {
+ return $this->decode(bin2hex($bytes));
+ }
+
+ /**
+ * Swaps the first 48 bits with the last 48 bits
+ *
+ * @param array $components An array of UUID components (the UUID exploded on its dashes)
+ *
+ * @return void
+ */
+ protected function swapTimestampAndRandomBits(array &$components)
+ {
+ $last48Bits = $components[4];
+ if (count($components) == 6) {
+ $last48Bits = $components[5];
+ $components[5] = $components[0] . $components[1];
+ } else {
+ $components[4] = $components[0] . $components[1];
+ }
+
+ $components[0] = substr($last48Bits, 0, 8);
+ $components[1] = substr($last48Bits, 8, 4);
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Codec/TimestampLastCombCodec.php b/vendor/ramsey/uuid/src/Codec/TimestampLastCombCodec.php
new file mode 100644
index 0000000000..0cdd009a4f
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Codec/TimestampLastCombCodec.php
@@ -0,0 +1,23 @@
+<?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\Codec;
+
+/**
+ * TimestampLastCombCodec encodes and decodes COMB UUIDs which have the timestamp as the last 48 bits.
+ * To be used with MSSQL.
+ */
+class TimestampLastCombCodec extends StringCodec
+{
+
+}
diff --git a/vendor/ramsey/uuid/src/Console/Application.php b/vendor/ramsey/uuid/src/Console/Application.php
deleted file mode 100644
index ddeff64517..0000000000
--- a/vendor/ramsey/uuid/src/Console/Application.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/**
- * This file is part of the Rhumsaa\Uuid library
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- *
- * @copyright Copyright (c) 2013-2014 Ben Ramsey <http://benramsey.com>
- * @license http://opensource.org/licenses/MIT MIT
- */
-
-namespace Rhumsaa\Uuid\Console;
-
-use Rhumsaa\Uuid\Console\Util;
-use Rhumsaa\Uuid\Uuid;
-use Symfony\Component\Console\Application as BaseApplication;
-
-/**
- * The console application that handles CLI commands
- */
-class Application extends BaseApplication
-{
- /**
- * Constructor
- */
- public function __construct()
- {
- Util\ErrorHandler::register();
- parent::__construct('uuid', Uuid::VERSION);
- }
-}
diff --git a/vendor/ramsey/uuid/src/Console/Command/DecodeCommand.php b/vendor/ramsey/uuid/src/Console/Command/DecodeCommand.php
deleted file mode 100644
index 0e00c7716b..0000000000
--- a/vendor/ramsey/uuid/src/Console/Command/DecodeCommand.php
+++ /dev/null
@@ -1,143 +0,0 @@
-<?php
-/**
- * This file is part of the Rhumsaa\Uuid library
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- *
- * @copyright Copyright (c) 2013-2014 Ben Ramsey <http://benramsey.com>
- * @license http://opensource.org/licenses/MIT MIT
- */
-
-namespace Rhumsaa\Uuid\Console\Command;
-
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
-use Rhumsaa\Uuid\Console\Exception;
-use Rhumsaa\Uuid\Uuid;
-
-/**
- * Provides the console command to decode UUIDs and dump information about them
- */
-class DecodeCommand extends Command
-{
- /**
- * {@inheritDoc}
- */
- protected function configure()
- {
- parent::configure();
-
- $this->setName('decode')
- ->setDescription('Decode a UUID and dump information about it')
- ->addArgument(
- 'uuid',
- InputArgument::REQUIRED,
- 'The UUID to decode.'
- );
- }
-
- /**
- * {@inheritDoc}
- *
- * @param InputInterface $input
- * @param OutputInterface $output
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- if (!Uuid::isValid($input->getArgument('uuid'))) {
- throw new Exception('Invalid UUID (' . $input->getArgument('uuid') . ')');
- }
-
- $uuid = Uuid::fromString($input->getArgument('uuid'));
-
- $table = $this->createTable($output);
- $this->setTableLayout($table);
-
- $table->addRows(array(
- array('encode:', 'STR:', (string) $uuid),
- array('', 'INT:', (string) $uuid->getInteger()),
- ));
-
- if ($uuid->getVariant() != Uuid::RFC_4122) {
- $table->addRows(array(
- array('decode:', 'variant:', 'Not an RFC 4122 UUID'),
- ));
-
- $table->render($output);
-
- return;
- }
-
- switch ($uuid->getVersion()) {
- case 1:
- $version = '1 (time and node based)';
- break;
- case 2:
- $version = '2 (DCE security based)';
- break;
- case 3:
- $version = '3 (name based, MD5)';
- break;
- case 4:
- $version = '4 (random data based)';
- break;
- case 5:
- $version = '5 (name based, SHA-1)';
- break;
- }
-
- $table->addRows(array(
- array('decode:', 'variant:', 'RFC 4122'),
- array('', 'version:', $version),
- ));
-
- if ($uuid->getVersion() == 1) {
- $table->addRows(array(
- array('', 'content:', 'time: ' . $uuid->getDateTime()->format('c')),
- array('', '', 'clock: ' . $uuid->getClockSequence() . ' (usually random)'),
- array('', '', 'node: ' . substr(chunk_split($uuid->getNodeHex(), 2, ':'), 0, -1)),
- ));
- }
-
- if ($uuid->getVersion() == 4) {
- $table->addRows(array(
- array('', 'content:', substr(chunk_split($uuid->getHex(), 2, ':'), 0, -1)),
- array('', '', '(no semantics: random data only)'),
- ));
- }
-
- if ($uuid->getVersion() == 3 || $uuid->getVersion() == 5) {
- $table->addRows(array(
- array('', 'content:', substr(chunk_split($uuid->getHex(), 2, ':'), 0, -1)),
- array('', '', '(not decipherable: MD5 message digest only)'),
- ));
- }
-
- $table->render($output);
- }
-
- protected function createTable(OutputInterface $output)
- {
- $class = 'Symfony\\Component\\Console\\Helper\\Table';
- if (class_exists($class)) {
- return new $class($output);
- }
-
- return $this->getHelperSet()->get('table');
- }
-
- /**
- * @param object $table
- */
- protected function setTableLayout($table)
- {
- if (method_exists($table, 'setLayout')) {
- $table->setLayout(1); // TableHelper::LAYOUT_BORDERLESS
- } else {
- $table->setStyle('borderless');
- }
- }
-}
diff --git a/vendor/ramsey/uuid/src/Console/Command/GenerateCommand.php b/vendor/ramsey/uuid/src/Console/Command/GenerateCommand.php
deleted file mode 100644
index a4c66043df..0000000000
--- a/vendor/ramsey/uuid/src/Console/Command/GenerateCommand.php
+++ /dev/null
@@ -1,167 +0,0 @@
-<?php
-/**
- * This file is part of the Rhumsaa\Uuid library
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- *
- * @copyright Copyright (c) 2013-2014 Ben Ramsey <http://benramsey.com>
- * @license http://opensource.org/licenses/MIT MIT
- */
-
-namespace Rhumsaa\Uuid\Console\Command;
-
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Output\OutputInterface;
-use Rhumsaa\Uuid\Console\Exception;
-use Rhumsaa\Uuid\Uuid;
-
-/**
- * Provides the console command to generate UUIDs
- */
-class GenerateCommand extends Command
-{
- /**
- * {@inheritDoc}
- */
- protected function configure()
- {
- parent::configure();
-
- $this->setName('generate')
- ->setDescription('Generate a UUID')
- ->addArgument(
- 'version',
- InputArgument::OPTIONAL,
- 'The UUID version to generate. Supported are version "1", "3", '
- . '"4" and "5".',
- 1
- )
- ->addArgument(
- 'namespace',
- InputArgument::OPTIONAL,
- 'For version 3 or 5 UUIDs, the namespace to create a UUID for. '
- . 'May be either a UUID in string representation or an identifier '
- . 'for internally pre-defined namespace UUIDs (currently known '
- . 'are "ns:DNS", "ns:URL", "ns:OID", and "ns:X500").'
- )
- ->addArgument(
- 'name',
- InputArgument::OPTIONAL,
- 'For version 3 or 5 UUIDs, the name to create a UUID for. '
- . 'The name is a string of arbitrary length.'
- )
- ->addOption(
- 'count',
- 'c',
- InputOption::VALUE_REQUIRED,
- 'Generate count UUIDs instead of just a single one.',
- 1
- );
- }
-
- /**
- * {@inheritDoc}
- *
- * @param InputInterface $input
- * @param OutputInterface $output
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- $uuids = array();
-
- $count = filter_var(
- $input->getOption('count'),
- FILTER_VALIDATE_INT,
- array(
- 'default' => 1,
- 'min_range' => 1,
- )
- );
-
- for ($i = 0; $i < $count; $i++) {
- $uuids[] = $this->createUuid(
- $input->getArgument('version'),
- $input->getArgument('namespace'),
- $input->getArgument('name')
- );
- }
-
- foreach ($uuids as $uuid) {
- $output->writeln((string) $uuid);
- }
- }
-
- /**
- * Creates the requested UUID
- *
- * @param int $version
- * @param string $namespace
- * @param string $name
- * @return Uuid
- */
- protected function createUuid($version, $namespace = null, $name = null)
- {
- switch ((int) $version) {
- case 1:
- $uuid = Uuid::uuid1();
- break;
- case 4:
- $uuid = Uuid::uuid4();
- break;
- case 3:
- case 5:
- $ns = $this->validateNamespace($namespace);
- if (empty($name)) {
- throw new Exception('The name argument is required for version 3 or 5 UUIDs');
- }
- if ($version == 3) {
- $uuid = Uuid::uuid3($ns, $name);
- } else {
- $uuid = Uuid::uuid5($ns, $name);
- }
- break;
- default:
- throw new Exception('Invalid UUID version. Supported are version "1", "3", "4", and "5".');
- }
-
- return $uuid;
- }
-
- /**
- * Validates the namespace argument
- *
- * @param string $namespace
- * @return string The namespace, if valid
- * @throws Exception
- */
- protected function validateNamespace($namespace)
- {
- switch ($namespace) {
- case 'ns:DNS':
- return Uuid::NAMESPACE_DNS;
- break;
- case 'ns:URL':
- return Uuid::NAMESPACE_URL;
- break;
- case 'ns:OID':
- return Uuid::NAMESPACE_OID;
- break;
- case 'ns:X500':
- return Uuid::NAMESPACE_X500;
- break;
- }
-
- if (Uuid::isValid($namespace)) {
- return $namespace;
- }
-
- throw new Exception('Invalid namespace. '
- . 'May be either a UUID in string representation or an identifier '
- . 'for internally pre-defined namespace UUIDs (currently known '
- . 'are "ns:DNS", "ns:URL", "ns:OID", and "ns:X500").');
- }
-}
diff --git a/vendor/ramsey/uuid/src/Console/Exception.php b/vendor/ramsey/uuid/src/Console/Exception.php
deleted file mode 100644
index aefef0d304..0000000000
--- a/vendor/ramsey/uuid/src/Console/Exception.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-/**
- * This file is part of the Rhumsaa\Uuid library
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- *
- * @copyright Copyright (c) 2013-2014 Ben Ramsey <http://benramsey.com>
- * @license http://opensource.org/licenses/MIT MIT
- */
-
-namespace Rhumsaa\Uuid\Console;
-
-/**
- * Console exception
- */
-class Exception extends \RuntimeException
-{
-}
diff --git a/vendor/ramsey/uuid/src/Console/Util/ErrorHandler.php b/vendor/ramsey/uuid/src/Console/Util/ErrorHandler.php
deleted file mode 100644
index fe4d90a33f..0000000000
--- a/vendor/ramsey/uuid/src/Console/Util/ErrorHandler.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-/**
- * This file is part of the Rhumsaa\Uuid library
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- *
- * @copyright Copyright (c) 2013-2014 Ben Ramsey <http://benramsey.com>
- * @license http://opensource.org/licenses/MIT MIT
- */
-
-namespace Rhumsaa\Uuid\Console\Util;
-
-/**
- * Convert PHP errors into exceptions
- */
-class ErrorHandler
-{
- /**
- * Error handler
- *
- * @param int $level Level of the error raised
- * @param string $message Error message
- * @param string $file Filename that the error was raised in
- * @param int $line Line number the error was raised at
- *
- * @static
- * @throws \ErrorException
- */
- public static function handle($level, $message, $file, $line)
- {
- // respect error_reporting being disabled
- if (!error_reporting()) {
- return;
- }
-
- throw new \ErrorException($message, 0, $level, $file, $line);
- }
-
- /**
- * Register error handler
- *
- * @static
- */
- public static function register()
- {
- set_error_handler(array(__CLASS__, 'handle'));
- }
-}
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 0000000000..d23512256e
--- /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);
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Converter/Number/DegradedNumberConverter.php b/vendor/ramsey/uuid/src/Converter/Number/DegradedNumberConverter.php
new file mode 100644
index 0000000000..96a011c653
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Converter/Number/DegradedNumberConverter.php
@@ -0,0 +1,58 @@
+<?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 Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
+use Ramsey\Uuid\Converter\NumberConverterInterface;
+
+/**
+ * DegradedNumberConverter throws `UnsatisfiedDependencyException` exceptions
+ * if attempting to use number conversion functionality in an environment that
+ * does not support large integers (i.e. when moontoast/math is not available)
+ */
+class DegradedNumberConverter implements NumberConverterInterface
+{
+ /**
+ * Throws an `UnsatisfiedDependencyException`
+ *
+ * @param string $hex The hexadecimal string representation to convert
+ * @return void
+ * @throws UnsatisfiedDependencyException
+ */
+ public function fromHex($hex)
+ {
+ throw new UnsatisfiedDependencyException(
+ 'Cannot call ' . __METHOD__ . ' without support for large '
+ . 'integers, since integer is an unsigned '
+ . '128-bit integer; Moontoast\Math\BigNumber is required.'
+ );
+ }
+
+ /**
+ * Throws an `UnsatisfiedDependencyException`
+ *
+ * @param mixed $integer An integer representation to convert
+ * @return void
+ * @throws UnsatisfiedDependencyException
+ */
+ public function toHex($integer)
+ {
+ throw new UnsatisfiedDependencyException(
+ 'Cannot call ' . __METHOD__ . ' without support for large '
+ . 'integers, since integer is an unsigned '
+ . '128-bit integer; Moontoast\Math\BigNumber is required. '
+ );
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Converter/NumberConverterInterface.php b/vendor/ramsey/uuid/src/Converter/NumberConverterInterface.php
new file mode 100644
index 0000000000..673c1df361
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Converter/NumberConverterInterface.php
@@ -0,0 +1,44 @@
+<?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;
+
+/**
+ * NumberConverterInterface converts UUIDs from hexadecimal characters into
+ * representations of integers and vice versa
+ */
+interface NumberConverterInterface
+{
+ /**
+ * Converts a hexadecimal number into an integer representation of the number
+ *
+ * The integer representation returned may be an object or a string
+ * representation of the integer, depending on the implementation.
+ *
+ * @param string $hex The hexadecimal string representation to convert
+ * @return mixed
+ */
+ public function fromHex($hex);
+
+ /**
+ * Converts an integer representation into a hexadecimal string representation
+ * of the number
+ *
+ * @param mixed $integer An integer representation to convert; this may be
+ * a true integer, a string integer, or a object representation that
+ * this converter can understand
+ * @return string Hexadecimal string
+ */
+ public function toHex($integer);
+}
diff --git a/vendor/ramsey/uuid/src/Converter/Time/BigNumberTimeConverter.php b/vendor/ramsey/uuid/src/Converter/Time/BigNumberTimeConverter.php
new file mode 100644
index 0000000000..d47c80191d
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Converter/Time/BigNumberTimeConverter.php
@@ -0,0 +1,58 @@
+<?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\Time;
+
+use Moontoast\Math\BigNumber;
+use Ramsey\Uuid\Converter\TimeConverterInterface;
+
+/**
+ * BigNumberTimeConverter uses the moontoast/math library's `BigNumber` to
+ * provide facilities for converting parts of time into representations that may
+ * be used in UUIDs
+ */
+class BigNumberTimeConverter implements TimeConverterInterface
+{
+ /**
+ * Uses the provided seconds and micro-seconds to calculate the time_low,
+ * time_mid, and time_high fields used by RFC 4122 version 1 UUIDs
+ *
+ * @param string $seconds
+ * @param string $microSeconds
+ * @return string[] An array containing `low`, `mid`, and `high` keys
+ * @link http://tools.ietf.org/html/rfc4122#section-4.2.2
+ */
+ public function calculateTime($seconds, $microSeconds)
+ {
+ $uuidTime = new BigNumber('0');
+
+ $sec = new BigNumber($seconds);
+ $sec->multiply('10000000');
+
+ $usec = new BigNumber($microSeconds);
+ $usec->multiply('10');
+
+ $uuidTime->add($sec)
+ ->add($usec)
+ ->add('122192928000000000');
+
+ $uuidTimeHex = sprintf('%016s', $uuidTime->convertToBase(16));
+
+ return array(
+ 'low' => substr($uuidTimeHex, 8),
+ 'mid' => substr($uuidTimeHex, 4, 4),
+ 'hi' => substr($uuidTimeHex, 0, 4),
+ );
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Converter/Time/DegradedTimeConverter.php b/vendor/ramsey/uuid/src/Converter/Time/DegradedTimeConverter.php
new file mode 100644
index 0000000000..46edbe78ed
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Converter/Time/DegradedTimeConverter.php
@@ -0,0 +1,42 @@
+<?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\Time;
+
+use Ramsey\Uuid\Converter\TimeConverterInterface;
+use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
+
+/**
+ * DegradedTimeConverter throws `UnsatisfiedDependencyException` exceptions
+ * if attempting to use time conversion functionality in an environment that
+ * does not support large integers (i.e. when moontoast/math is not available)
+ */
+class DegradedTimeConverter implements TimeConverterInterface
+{
+ /**
+ * Throws an `UnsatisfiedDependencyException`
+ *
+ * @param string $seconds
+ * @param string $microSeconds
+ * @return void
+ * @throws UnsatisfiedDependencyException
+ */
+ public function calculateTime($seconds, $microSeconds)
+ {
+ throw new UnsatisfiedDependencyException(
+ 'When calling ' . __METHOD__ . ' on a 32-bit system, '
+ . 'Moontoast\Math\BigNumber must be present.'
+ );
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php b/vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php
new file mode 100644
index 0000000000..6a9da74b83
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php
@@ -0,0 +1,47 @@
+<?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\Time;
+
+use Ramsey\Uuid\Converter\TimeConverterInterface;
+
+/**
+ * PhpTimeConverter uses built-in PHP functions and standard math operations
+ * available to the PHP programming language to provide facilities for
+ * converting parts of time into representations that may be used in UUIDs
+ */
+class PhpTimeConverter implements TimeConverterInterface
+{
+ /**
+ * Uses the provided seconds and micro-seconds to calculate the time_low,
+ * time_mid, and time_high fields used by RFC 4122 version 1 UUIDs
+ *
+ * @param string $seconds
+ * @param string $microSeconds
+ * @return string[] An array containing `low`, `mid`, and `high` keys
+ * @link http://tools.ietf.org/html/rfc4122#section-4.2.2
+ */
+ public function calculateTime($seconds, $microSeconds)
+ {
+ // 0x01b21dd213814000 is the number of 100-ns intervals between the
+ // UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
+ $uuidTime = ($seconds * 10000000) + ($microSeconds * 10) + 0x01b21dd213814000;
+
+ return array(
+ 'low' => sprintf('%08x', $uuidTime & 0xffffffff),
+ 'mid' => sprintf('%04x', ($uuidTime >> 32) & 0xffff),
+ 'hi' => sprintf('%04x', ($uuidTime >> 48) & 0x0fff),
+ );
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Converter/TimeConverterInterface.php b/vendor/ramsey/uuid/src/Converter/TimeConverterInterface.php
new file mode 100644
index 0000000000..f0688367bf
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Converter/TimeConverterInterface.php
@@ -0,0 +1,33 @@
+<?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;
+
+/**
+ * TimeConverterInterface provides facilities for converting parts of time into
+ * representations that may be used in UUIDs
+ */
+interface TimeConverterInterface
+{
+ /**
+ * Uses the provided seconds and micro-seconds to calculate the time_low,
+ * time_mid, and time_high fields used by RFC 4122 version 1 UUIDs
+ *
+ * @param string $seconds
+ * @param string $microSeconds
+ * @return string[] An array guaranteed to contain `low`, `mid`, and `high` keys
+ * @link http://tools.ietf.org/html/rfc4122#section-4.2.2
+ */
+ public function calculateTime($seconds, $microSeconds);
+}
diff --git a/vendor/ramsey/uuid/src/DegradedUuid.php b/vendor/ramsey/uuid/src/DegradedUuid.php
new file mode 100644
index 0000000000..b596c38838
--- /dev/null
+++ b/vendor/ramsey/uuid/src/DegradedUuid.php
@@ -0,0 +1,111 @@
+<?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;
+
+use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
+use Ramsey\Uuid\Exception\UnsupportedOperationException;
+
+/**
+ * DegradedUuid represents an RFC 4122 UUID on 32-bit systems
+ *
+ * @see Uuid
+ */
+class DegradedUuid extends Uuid
+{
+ public function getDateTime()
+ {
+ if ($this->getVersion() != 1) {
+ throw new UnsupportedOperationException('Not a time-based UUID');
+ }
+
+ $time = $this->converter->fromHex($this->getTimestampHex());
+
+ $ts = new \Moontoast\Math\BigNumber($time, 20);
+ $ts->subtract('122192928000000000');
+ $ts->divide('10000000.0');
+ $ts->round();
+ $unixTime = $ts->getValue();
+
+ return new \DateTime("@{$unixTime}");
+ }
+
+ /**
+ * For degraded UUIDs, throws an `UnsatisfiedDependencyException` when
+ * called on a 32-bit system
+ *
+ * @throws UnsatisfiedDependencyException if called on a 32-bit system
+ */
+ public function getFields()
+ {
+ throw new UnsatisfiedDependencyException(
+ 'Cannot call ' . __METHOD__ . ' on a 32-bit system, since some '
+ . 'values overflow the system max integer value'
+ . '; consider calling getFieldsHex instead'
+ );
+ }
+
+ /**
+ * For degraded UUIDs, throws an `UnsatisfiedDependencyException` when
+ * called on a 32-bit system
+ *
+ * @throws UnsatisfiedDependencyException if called on a 32-bit system
+ */
+ public function getNode()
+ {
+ throw new UnsatisfiedDependencyException(
+ 'Cannot call ' . __METHOD__ . ' on a 32-bit system, since node '
+ . 'is an unsigned 48-bit integer and can overflow the system '
+ . 'max integer value'
+ . '; consider calling getNodeHex instead'
+ );
+ }
+
+ /**
+ * For degraded UUIDs, throws an `UnsatisfiedDependencyException` when
+ * called on a 32-bit system
+ *
+ * @throws UnsatisfiedDependencyException if called on a 32-bit system
+ */
+ public function getTimeLow()
+ {
+ throw new UnsatisfiedDependencyException(
+ 'Cannot call ' . __METHOD__ . ' on a 32-bit system, since time_low '
+ . 'is an unsigned 32-bit integer and can overflow the system '
+ . 'max integer value'
+ . '; consider calling getTimeLowHex instead'
+ );
+ }
+
+ /**
+ * For degraded UUIDs, throws an `UnsatisfiedDependencyException` when
+ * called on a 32-bit system
+ *
+ * @throws UnsatisfiedDependencyException if called on a 32-bit system
+ * @throws UnsupportedOperationException If this UUID is not a version 1 UUID
+ */
+ public function getTimestamp()
+ {
+ if ($this->getVersion() != 1) {
+ throw new UnsupportedOperationException('Not a time-based UUID');
+ }
+
+ throw new UnsatisfiedDependencyException(
+ 'Cannot call ' . __METHOD__ . ' on a 32-bit system, since timestamp '
+ . 'is an unsigned 60-bit integer and can overflow the system '
+ . 'max integer value'
+ . '; consider calling getTimestampHex instead'
+ );
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Doctrine/UuidType.php b/vendor/ramsey/uuid/src/Doctrine/UuidType.php
deleted file mode 100644
index ffecee8fb0..0000000000
--- a/vendor/ramsey/uuid/src/Doctrine/UuidType.php
+++ /dev/null
@@ -1,108 +0,0 @@
-<?php
-/**
- * This file is part of the Rhumsaa\Uuid library
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- *
- * @copyright Copyright (c) 2013-2014 Ben Ramsey <http://benramsey.com>
- * @license http://opensource.org/licenses/MIT MIT
- */
-
-namespace Rhumsaa\Uuid\Doctrine;
-
-use InvalidArgumentException;
-use Rhumsaa\Uuid\Uuid;
-use Doctrine\DBAL\Types\ConversionException;
-use Doctrine\DBAL\Types\Type;
-use Doctrine\DBAL\Platforms\AbstractPlatform;
-
-/**
- * Field type mapping for the Doctrine Database Abstraction Layer (DBAL).
- *
- * UUID fields will be stored as a string in the database and converted back to
- * the Uuid value object when querying.
- */
-class UuidType extends Type
-{
- /**
- * @var string
- */
- const NAME = 'uuid';
-
- /**
- * {@inheritdoc}
- *
- * @param array $fieldDeclaration
- * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
- */
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
- {
- return $platform->getGuidTypeDeclarationSQL($fieldDeclaration);
- }
-
- /**
- * {@inheritdoc}
- *
- * @param string|null $value
- * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
- */
- public function convertToPHPValue($value, AbstractPlatform $platform)
- {
- if (empty($value)) {
- return null;
- }
-
- if ($value instanceof Uuid) {
- return $value;
- }
-
- try {
- $uuid = Uuid::fromString($value);
- } catch (InvalidArgumentException $e) {
- throw ConversionException::conversionFailed($value, self::NAME);
- }
-
- return $uuid;
- }
-
- /**
- * {@inheritdoc}
- *
- * @param Uuid|null $value
- * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
- */
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
- {
- if (empty($value)) {
- return null;
- }
-
- if ($value instanceof Uuid || Uuid::isValid($value)) {
- return (string) $value;
- }
-
- throw ConversionException::conversionFailed($value, self::NAME);
- }
-
- /**
- * {@inheritdoc}
- *
- * @return string
- */
- public function getName()
- {
- return self::NAME;
- }
-
- /**
- * {@inheritdoc}
- *
- * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
- * @return boolean
- */
- public function requiresSQLCommentHint(AbstractPlatform $platform)
- {
- return true;
- }
-}
diff --git a/vendor/ramsey/uuid/src/Exception/InvalidUuidStringException.php b/vendor/ramsey/uuid/src/Exception/InvalidUuidStringException.php
new file mode 100644
index 0000000000..0e480649da
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Exception/InvalidUuidStringException.php
@@ -0,0 +1,22 @@
+<?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\Exception;
+
+/**
+ * Thrown to indicate that the parsed UUID string is invalid.
+ */
+class InvalidUuidStringException extends \InvalidArgumentException
+{
+}
diff --git a/vendor/ramsey/uuid/src/Exception/UnsatisfiedDependencyException.php b/vendor/ramsey/uuid/src/Exception/UnsatisfiedDependencyException.php
index e402837543..8b5d5d08ed 100644
--- a/vendor/ramsey/uuid/src/Exception/UnsatisfiedDependencyException.php
+++ b/vendor/ramsey/uuid/src/Exception/UnsatisfiedDependencyException.php
@@ -1,15 +1,18 @@
<?php
/**
- * This file is part of the Rhumsaa\Uuid library
+ * 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) 2013-2014 Ben Ramsey <http://benramsey.com>
+ * @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 Rhumsaa\Uuid\Exception;
+namespace Ramsey\Uuid\Exception;
/**
* Thrown to indicate that the requested operation has dependencies that have not
diff --git a/vendor/ramsey/uuid/src/Exception/UnsupportedOperationException.php b/vendor/ramsey/uuid/src/Exception/UnsupportedOperationException.php
index e9eed08bb2..b371b6823d 100644
--- a/vendor/ramsey/uuid/src/Exception/UnsupportedOperationException.php
+++ b/vendor/ramsey/uuid/src/Exception/UnsupportedOperationException.php
@@ -1,15 +1,18 @@
<?php
/**
- * This file is part of the Rhumsaa\Uuid library
+ * 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) 2013-2014 Ben Ramsey <http://benramsey.com>
+ * @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 Rhumsaa\Uuid\Exception;
+namespace Ramsey\Uuid\Exception;
/**
* Thrown to indicate that the requested operation is not supported.
diff --git a/vendor/ramsey/uuid/src/FeatureSet.php b/vendor/ramsey/uuid/src/FeatureSet.php
new file mode 100644
index 0000000000..56a774eabe
--- /dev/null
+++ b/vendor/ramsey/uuid/src/FeatureSet.php
@@ -0,0 +1,333 @@
+<?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;
+
+use Ramsey\Uuid\Converter\TimeConverterInterface;
+use Ramsey\Uuid\Generator\PeclUuidTimeGenerator;
+use Ramsey\Uuid\Provider\Node\FallbackNodeProvider;
+use Ramsey\Uuid\Provider\Node\RandomNodeProvider;
+use Ramsey\Uuid\Provider\Node\SystemNodeProvider;
+use Ramsey\Uuid\Converter\NumberConverterInterface;
+use Ramsey\Uuid\Converter\Number\BigNumberConverter;
+use Ramsey\Uuid\Converter\Number\DegradedNumberConverter;
+use Ramsey\Uuid\Converter\Time\BigNumberTimeConverter;
+use Ramsey\Uuid\Converter\Time\DegradedTimeConverter;
+use Ramsey\Uuid\Converter\Time\PhpTimeConverter;
+use Ramsey\Uuid\Provider\Time\SystemTimeProvider;
+use Ramsey\Uuid\Builder\UuidBuilderInterface;
+use Ramsey\Uuid\Builder\DefaultUuidBuilder;
+use Ramsey\Uuid\Codec\CodecInterface;
+use Ramsey\Uuid\Codec\StringCodec;
+use Ramsey\Uuid\Codec\GuidStringCodec;
+use Ramsey\Uuid\Builder\DegradedUuidBuilder;
+use Ramsey\Uuid\Generator\RandomGeneratorFactory;
+use Ramsey\Uuid\Generator\RandomGeneratorInterface;
+use Ramsey\Uuid\Generator\TimeGeneratorFactory;
+use Ramsey\Uuid\Generator\TimeGeneratorInterface;
+use Ramsey\Uuid\Provider\TimeProviderInterface;
+use Ramsey\Uuid\Provider\NodeProviderInterface;
+
+/**
+ * FeatureSet detects and exposes available features in the current environment
+ * (32- or 64-bit, available dependencies, etc.)
+ */
+class FeatureSet
+{
+ /**
+ * @var bool
+ */
+ private $disableBigNumber = false;
+
+ /**
+ * @var bool
+ */
+ private $disable64Bit = false;
+
+ /**
+ * @var bool
+ */
+ private $ignoreSystemNode = false;
+
+ /**
+ * @var bool
+ */
+ private $enablePecl = false;
+
+ /**
+ * @var UuidBuilderInterface
+ */
+ private $builder;
+
+ /**
+ * @var CodecInterface
+ */
+ private $codec;
+
+ /**
+ * @var NodeProviderInterface
+ */
+ private $nodeProvider;
+
+ /**
+ * @var NumberConverterInterface
+ */
+ private $numberConverter;
+
+ /**
+ * @var RandomGeneratorInterface
+ */
+ private $randomGenerator;
+
+ /**
+ * @var TimeGeneratorInterface
+ */
+ private $timeGenerator;
+
+ /**
+ * Constructs a `FeatureSet` for use by a `UuidFactory` to determine or set
+ * features available to the environment
+ *
+ * @param bool $useGuids Whether to build UUIDs using the `GuidStringCodec`
+ * @param bool $force32Bit Whether to force the use of 32-bit functionality
+ * (primarily for testing purposes)
+ * @param bool $forceNoBigNumber Whether to disable the use of moontoast/math
+ * `BigNumber` (primarily for testing purposes)
+ * @param bool $ignoreSystemNode Whether to disable attempts to check for
+ * the system host ID (primarily for testing purposes)
+ * @param bool $enablePecl Whether to enable the use of the `PeclUuidTimeGenerator`
+ * to generate version 1 UUIDs
+ */
+ public function __construct(
+ $useGuids = false,
+ $force32Bit = false,
+ $forceNoBigNumber = false,
+ $ignoreSystemNode = false,
+ $enablePecl = false
+ ) {
+ $this->disableBigNumber = $forceNoBigNumber;
+ $this->disable64Bit = $force32Bit;
+ $this->ignoreSystemNode = $ignoreSystemNode;
+ $this->enablePecl = $enablePecl;
+
+ $this->numberConverter = $this->buildNumberConverter();
+ $this->builder = $this->buildUuidBuilder();
+ $this->codec = $this->buildCodec($useGuids);
+ $this->nodeProvider = $this->buildNodeProvider();
+ $this->randomGenerator = $this->buildRandomGenerator();
+ $this->setTimeProvider(new SystemTimeProvider());
+ }
+
+ /**
+ * Returns the builder configured for this environment
+ *
+ * @return UuidBuilderInterface
+ */
+ public function getBuilder()
+ {
+ return $this->builder;
+ }
+
+ /**
+ * Returns the UUID UUID coder-decoder configured for this environment
+ *
+ * @return CodecInterface
+ */
+ public function getCodec()
+ {
+ return $this->codec;
+ }
+
+ /**
+ * Returns the system node ID provider configured for this environment
+ *
+ * @return NodeProviderInterface
+ */
+ public function getNodeProvider()
+ {
+ return $this->nodeProvider;
+ }
+
+ /**
+ * Returns the number converter configured for this environment
+ *
+ * @return NumberConverterInterface
+ */
+ public function getNumberConverter()
+ {
+ return $this->numberConverter;
+ }
+
+ /**
+ * Returns the random UUID generator configured for this environment
+ *
+ * @return RandomGeneratorInterface
+ */
+ public function getRandomGenerator()
+ {
+ return $this->randomGenerator;
+ }
+
+ /**
+ * Returns the time-based UUID generator configured for this environment
+ *
+ * @return TimeGeneratorInterface
+ */
+ public function getTimeGenerator()
+ {
+ return $this->timeGenerator;
+ }
+
+ /**
+ * Sets the time provider for use in this environment
+ *
+ * @param TimeProviderInterface $timeProvider
+ */
+ public function setTimeProvider(TimeProviderInterface $timeProvider)
+ {
+ $this->timeGenerator = $this->buildTimeGenerator($timeProvider);
+ }
+
+ /**
+ * Determines which UUID coder-decoder to use and returns the configured
+ * codec for this environment
+ *
+ * @param bool $useGuids Whether to build UUIDs using the `GuidStringCodec`
+ * @return CodecInterface
+ */
+ protected function buildCodec($useGuids = false)
+ {
+ if ($useGuids) {
+ return new GuidStringCodec($this->builder);
+ }
+
+ return new StringCodec($this->builder);
+ }
+
+ /**
+ * Determines which system node ID provider to use and returns the configured
+ * system node ID provider for this environment
+ *
+ * @return NodeProviderInterface
+ */
+ protected function buildNodeProvider()
+ {
+ if ($this->ignoreSystemNode) {
+ return new RandomNodeProvider();
+ }
+
+ return new FallbackNodeProvider([
+ new SystemNodeProvider(),
+ new RandomNodeProvider()
+ ]);
+ }
+
+ /**
+ * Determines which number converter to use and returns the configured
+ * number converter for this environment
+ *
+ * @return NumberConverterInterface
+ */
+ protected function buildNumberConverter()
+ {
+ if ($this->hasBigNumber()) {
+ return new BigNumberConverter();
+ }
+
+ return new DegradedNumberConverter();
+ }
+
+ /**
+ * Determines which random UUID generator to use and returns the configured
+ * random UUID generator for this environment
+ *
+ * @return RandomGeneratorInterface
+ */
+ protected function buildRandomGenerator()
+ {
+ return (new RandomGeneratorFactory())->getGenerator();
+ }
+
+ /**
+ * Determines which time-based UUID generator to use and returns the configured
+ * time-based UUID generator for this environment
+ *
+ * @param TimeProviderInterface $timeProvider
+ * @return TimeGeneratorInterface
+ */
+ protected function buildTimeGenerator(TimeProviderInterface $timeProvider)
+ {
+ if ($this->enablePecl) {
+ return new PeclUuidTimeGenerator();
+ }
+
+ return (new TimeGeneratorFactory(
+ $this->nodeProvider,
+ $this->buildTimeConverter(),
+ $timeProvider
+ ))->getGenerator();
+ }
+
+ /**
+ * Determines which time converter to use and returns the configured
+ * time converter for this environment
+ *
+ * @return TimeConverterInterface
+ */
+ protected function buildTimeConverter()
+ {
+ if ($this->is64BitSystem()) {
+ return new PhpTimeConverter();
+ } elseif ($this->hasBigNumber()) {
+ return new BigNumberTimeConverter();
+ }
+
+ return new DegradedTimeConverter();
+ }
+
+ /**
+ * Determines which UUID builder to use and returns the configured UUID
+ * builder for this environment
+ *
+ * @return UuidBuilderInterface
+ */
+ protected function buildUuidBuilder()
+ {
+ if ($this->is64BitSystem()) {
+ return new DefaultUuidBuilder($this->numberConverter);
+ }
+
+ return new DegradedUuidBuilder($this->numberConverter);
+ }
+
+ /**
+ * Returns true if the system has `Moontoast\Math\BigNumber`
+ *
+ * @return bool
+ */
+ protected function hasBigNumber()
+ {
+ return class_exists('Moontoast\Math\BigNumber') && !$this->disableBigNumber;
+ }
+
+ /**
+ * Returns true if the system is 64-bit, false otherwise
+ *
+ * @return bool
+ */
+ protected function is64BitSystem()
+ {
+ return PHP_INT_SIZE == 8 && !$this->disable64Bit;
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Generator/CombGenerator.php b/vendor/ramsey/uuid/src/Generator/CombGenerator.php
new file mode 100644
index 0000000000..1a4277673a
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Generator/CombGenerator.php
@@ -0,0 +1,85 @@
+<?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\Generator;
+
+use Ramsey\Uuid\Converter\NumberConverterInterface;
+
+/**
+ * CombGenerator provides functionality to generate COMB (combined GUID/timestamp)
+ * sequential UUIDs
+ *
+ * @link https://en.wikipedia.org/wiki/Globally_unique_identifier#Sequential_algorithms
+ */
+class CombGenerator implements RandomGeneratorInterface
+{
+ const TIMESTAMP_BYTES = 6;
+
+ /**
+ * @var RandomGeneratorInterface
+ */
+ private $randomGenerator;
+
+ /**
+ * @var NumberConverterInterface
+ */
+ private $converter;
+
+ /**
+ * Constructs a `CombGenerator` using a random-number generator and a number converter
+ *
+ * @param RandomGeneratorInterface $generator Random-number generator for the non-time part.
+ * @param NumberConverterInterface $numberConverter Instance of number converter.
+ */
+ public function __construct(RandomGeneratorInterface $generator, NumberConverterInterface $numberConverter)
+ {
+ $this->converter = $numberConverter;
+ $this->randomGenerator = $generator;
+ }
+
+ /**
+ * Generates a string of binary data of the specified length
+ *
+ * @param integer $length The number of bytes of random binary data to generate
+ * @return string A binary string
+ */
+ public function generate($length)
+ {
+ if ($length < self::TIMESTAMP_BYTES || $length < 0) {
+ throw new \InvalidArgumentException('Length must be a positive integer.');
+ }
+
+ $hash = '';
+
+ if (self::TIMESTAMP_BYTES > 0 && $length > self::TIMESTAMP_BYTES) {
+ $hash = $this->randomGenerator->generate($length - self::TIMESTAMP_BYTES);
+ }
+
+ $lsbTime = str_pad($this->converter->toHex($this->timestamp()), self::TIMESTAMP_BYTES * 2, '0', STR_PAD_LEFT);
+
+ return hex2bin(str_pad(bin2hex($hash), $length - self::TIMESTAMP_BYTES, '0') . $lsbTime);
+ }
+
+ /**
+ * Returns current timestamp as integer, precise to 0.00001 seconds
+ *
+ * @return string
+ */
+ private function timestamp()
+ {
+ $time = explode(' ', microtime(false));
+
+ return $time[1] . substr($time[0], 2, 5);
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php b/vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php
new file mode 100644
index 0000000000..f8f1ff1892
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php
@@ -0,0 +1,132 @@
+<?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\Generator;
+
+use Ramsey\Uuid\BinaryUtils;
+use Ramsey\Uuid\Converter\TimeConverterInterface;
+use Ramsey\Uuid\Provider\NodeProviderInterface;
+use Ramsey\Uuid\Provider\TimeProviderInterface;
+
+/**
+ * DefaultTimeGenerator provides functionality to generate strings of binary
+ * data for version 1 UUIDs based on a host ID, sequence number, and the current
+ * time
+ */
+class DefaultTimeGenerator implements TimeGeneratorInterface
+{
+ /**
+ * @var NodeProviderInterface
+ */
+ private $nodeProvider;
+
+ /**
+ * @var TimeConverterInterface
+ */
+ private $timeConverter;
+
+ /**
+ * @var TimeProviderInterface
+ */
+ private $timeProvider;
+
+ /**
+ * Constructs a `DefaultTimeGenerator` using a node provider, time converter,
+ * and time provider
+ *
+ * @param NodeProviderInterface $nodeProvider
+ * @param TimeConverterInterface $timeConverter
+ * @param TimeProviderInterface $timeProvider
+ */
+ public function __construct(
+ NodeProviderInterface $nodeProvider,
+ TimeConverterInterface $timeConverter,
+ TimeProviderInterface $timeProvider
+ ) {
+ $this->nodeProvider = $nodeProvider;
+ $this->timeConverter = $timeConverter;
+ $this->timeProvider = $timeProvider;
+ }
+
+ /**
+ * Generate a version 1 UUID from a host ID, sequence number, and the current time
+ *
+ * If $node is not given, we will attempt to obtain the local hardware
+ * address. If $clockSeq is given, it is used as the sequence number;
+ * otherwise a random 14-bit sequence number is chosen.
+ *
+ * @param int|string $node A 48-bit number representing the hardware address
+ * This number may be represented as an integer or a hexadecimal string.
+ * @param int $clockSeq A 14-bit number used to help avoid duplicates that
+ * could arise when the clock is set backwards in time or if the node ID
+ * changes.
+ * @return string A binary string
+ */
+ public function generate($node = null, $clockSeq = null)
+ {
+ $node = $this->getValidNode($node);
+
+ if ($clockSeq === null) {
+ // Not using "stable storage"; see RFC 4122, Section 4.2.1.1
+ $clockSeq = mt_rand(0, 1 << 14);
+ }
+
+ // Create a 60-bit time value as a count of 100-nanosecond intervals
+ // since 00:00:00.00, 15 October 1582
+ $timeOfDay = $this->timeProvider->currentTime();
+ $uuidTime = $this->timeConverter->calculateTime($timeOfDay['sec'], $timeOfDay['usec']);
+
+ $timeHi = BinaryUtils::applyVersion($uuidTime['hi'], 1);
+ $clockSeqHi = BinaryUtils::applyVariant($clockSeq >> 8);
+
+ $hex = vsprintf(
+ '%08s%04s%04s%02s%02s%012s',
+ array(
+ $uuidTime['low'],
+ $uuidTime['mid'],
+ sprintf('%04x', $timeHi),
+ sprintf('%02x', $clockSeqHi),
+ sprintf('%02x', $clockSeq & 0xff),
+ $node,
+ )
+ );
+
+ return hex2bin($hex);
+ }
+
+ /**
+ * Uses the node provider given when constructing this instance to get
+ * the node ID (usually a MAC address)
+ *
+ * @param string|int $node A node value that may be used to override the node provider
+ * @return string Hexadecimal representation of the node ID
+ */
+ protected function getValidNode($node)
+ {
+ if ($node === null) {
+ $node = $this->nodeProvider->getNode();
+ }
+
+ // Convert the node to hex, if it is still an integer
+ if (is_int($node)) {
+ $node = sprintf('%012x', $node);
+ }
+
+ if (!ctype_xdigit($node) || strlen($node) > 12) {
+ throw new \InvalidArgumentException('Invalid node value');
+ }
+
+ return strtolower(sprintf('%012s', $node));
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Generator/MtRandGenerator.php b/vendor/ramsey/uuid/src/Generator/MtRandGenerator.php
new file mode 100644
index 0000000000..f58b783574
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Generator/MtRandGenerator.php
@@ -0,0 +1,41 @@
+<?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\Generator;
+
+/**
+ * MtRandRandomGenerator provides functionality to generate strings of random
+ * binary data using the `mt_rand()` PHP function
+ *
+ * @link http://php.net/mt_rand
+ */
+class MtRandGenerator implements RandomGeneratorInterface
+{
+ /**
+ * Generates a string of random binary data of the specified length
+ *
+ * @param integer $length The number of bytes of random binary data to generate
+ * @return string A binary string
+ */
+ public function generate($length)
+ {
+ $bytes = '';
+
+ for ($i = 1; $i <= $length; $i++) {
+ $bytes = chr(mt_rand(0, 255)) . $bytes;
+ }
+
+ return $bytes;
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Generator/OpenSslGenerator.php b/vendor/ramsey/uuid/src/Generator/OpenSslGenerator.php
new file mode 100644
index 0000000000..e8ec6a4d84
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Generator/OpenSslGenerator.php
@@ -0,0 +1,38 @@
+<?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\Generator;
+
+/**
+ * OpenSslRandomGenerator provides functionality to generate strings of random
+ * binary data using the `openssl_random_pseudo_bytes()` PHP function
+ *
+ * The use of this generator requires PHP to be compiled using the
+ * `--with-openssl` option.
+ *
+ * @link http://php.net/openssl_random_pseudo_bytes
+ */
+class OpenSslGenerator implements RandomGeneratorInterface
+{
+ /**
+ * Generates a string of random binary data of the specified length
+ *
+ * @param integer $length The number of bytes of random binary data to generate
+ * @return string A binary string
+ */
+ public function generate($length)
+ {
+ return openssl_random_pseudo_bytes($length);
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Generator/PeclUuidRandomGenerator.php b/vendor/ramsey/uuid/src/Generator/PeclUuidRandomGenerator.php
new file mode 100644
index 0000000000..fc2ef7e4da
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Generator/PeclUuidRandomGenerator.php
@@ -0,0 +1,37 @@
+<?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\Generator;
+
+/**
+ * PeclUuidRandomGenerator provides functionality to generate strings of random
+ * binary data using the PECL UUID PHP extension
+ *
+ * @link https://pecl.php.net/package/uuid
+ */
+class PeclUuidRandomGenerator implements RandomGeneratorInterface
+{
+ /**
+ * Generates a string of random binary data of the specified length
+ *
+ * @param integer $length The number of bytes of random binary data to generate
+ * @return string A binary string
+ */
+ public function generate($length)
+ {
+ $uuid = uuid_create(UUID_TYPE_RANDOM);
+
+ return uuid_parse($uuid);
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Generator/PeclUuidTimeGenerator.php b/vendor/ramsey/uuid/src/Generator/PeclUuidTimeGenerator.php
new file mode 100644
index 0000000000..7ccf16fd9a
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Generator/PeclUuidTimeGenerator.php
@@ -0,0 +1,38 @@
+<?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\Generator;
+
+/**
+ * PeclUuidTimeGenerator provides functionality to generate strings of binary
+ * data for version 1 UUIDs using the PECL UUID PHP extension
+ *
+ * @link https://pecl.php.net/package/uuid
+ */
+class PeclUuidTimeGenerator implements TimeGeneratorInterface
+{
+ /**
+ * Generate a version 1 UUID using the PECL UUID extension
+ *
+ * @param int|string $node Not used in this context
+ * @param int $clockSeq Not used in this context
+ * @return string A binary string
+ */
+ public function generate($node = null, $clockSeq = null)
+ {
+ $uuid = uuid_create(UUID_TYPE_TIME);
+
+ return uuid_parse($uuid);
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php b/vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php
new file mode 100644
index 0000000000..1e8392abf6
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php
@@ -0,0 +1,36 @@
+<?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\Generator;
+
+/**
+ * RandomBytesGenerator provides functionality to generate strings of random
+ * binary data using `random_bytes()` function in PHP 7+ or paragonie/random_compat
+ *
+ * @link http://php.net/random_bytes
+ * @link https://github.com/paragonie/random_compat
+ */
+class RandomBytesGenerator implements RandomGeneratorInterface
+{
+ /**
+ * Generates a string of random binary data of the specified length
+ *
+ * @param integer $length The number of bytes of random binary data to generate
+ * @return string A binary string
+ */
+ public function generate($length)
+ {
+ return random_bytes($length);
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Generator/RandomGeneratorFactory.php b/vendor/ramsey/uuid/src/Generator/RandomGeneratorFactory.php
new file mode 100644
index 0000000000..39110622f4
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Generator/RandomGeneratorFactory.php
@@ -0,0 +1,31 @@
+<?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\Generator;
+
+/**
+ * A factory for retrieving a random generator, based on the environment
+ */
+class RandomGeneratorFactory
+{
+ /**
+ * Returns a default random generator, based on the current environment
+ *
+ * @return RandomGeneratorInterface
+ */
+ public static function getGenerator()
+ {
+ return new RandomBytesGenerator();
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php b/vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php
new file mode 100644
index 0000000000..87ccbc9544
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php
@@ -0,0 +1,30 @@
+<?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\Generator;
+
+/**
+ * RandomGeneratorInterface provides functionality to generate strings of random
+ * binary data
+ */
+interface RandomGeneratorInterface
+{
+ /**
+ * Generates a string of random binary data of the specified length
+ *
+ * @param integer $length The number of bytes of random binary data to generate
+ * @return string A binary string
+ */
+ public function generate($length);
+}
diff --git a/vendor/ramsey/uuid/src/Generator/RandomLibAdapter.php b/vendor/ramsey/uuid/src/Generator/RandomLibAdapter.php
new file mode 100644
index 0000000000..25b54a8349
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Generator/RandomLibAdapter.php
@@ -0,0 +1,62 @@
+<?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\Generator;
+
+use RandomLib\Generator;
+use RandomLib\Factory;
+
+/**
+ * RandomLibAdapter provides functionality to generate strings of random
+ * binary data using the ircmaxell/random-lib library
+ *
+ * @link https://packagist.org/packages/ircmaxell/random-lib
+ */
+class RandomLibAdapter implements RandomGeneratorInterface
+{
+ /**
+ * @var Generator
+ */
+ private $generator;
+
+ /**
+ * Constructs a `RandomLibAdapter` using a `RandomLib\Generator`
+ *
+ * By default, if no `Generator` is passed in, this creates a medium-strength
+ * generator to use when generating random binary data.
+ *
+ * @param Generator $generator An ircmaxell/random-lib `Generator`
+ */
+ public function __construct(Generator $generator = null)
+ {
+ $this->generator = $generator;
+
+ if ($this->generator === null) {
+ $factory = new Factory();
+
+ $this->generator = $factory->getMediumStrengthGenerator();
+ }
+ }
+
+ /**
+ * Generates a string of random binary data of the specified length
+ *
+ * @param integer $length The number of bytes of random binary data to generate
+ * @return string A binary string
+ */
+ public function generate($length)
+ {
+ return $this->generator->generate($length);
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Generator/SodiumRandomGenerator.php b/vendor/ramsey/uuid/src/Generator/SodiumRandomGenerator.php
new file mode 100644
index 0000000000..6b08f5402e
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Generator/SodiumRandomGenerator.php
@@ -0,0 +1,36 @@
+<?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\Generator;
+
+/**
+ * SodiumRandomGenerator provides functionality to generate strings of random
+ * binary data using the PECL libsodium extension
+ *
+ * @link http://pecl.php.net/package/libsodium
+ * @link https://paragonie.com/book/pecl-libsodium
+ */
+class SodiumRandomGenerator implements RandomGeneratorInterface
+{
+ /**
+ * Generates a string of random binary data of the specified length
+ *
+ * @param integer $length The number of bytes of random binary data to generate
+ * @return string A binary string
+ */
+ public function generate($length)
+ {
+ return \Sodium\randombytes_buf($length);
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php b/vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php
new file mode 100644
index 0000000000..24d501bbf3
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php
@@ -0,0 +1,72 @@
+<?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\Generator;
+
+use Ramsey\Uuid\Converter\TimeConverterInterface;
+use Ramsey\Uuid\Provider\NodeProviderInterface;
+use Ramsey\Uuid\Provider\TimeProviderInterface;
+
+/**
+ * A factory for retrieving a time generator, based on the environment
+ */
+class TimeGeneratorFactory
+{
+ /**
+ * @var NodeProviderInterface
+ */
+ private $nodeProvider;
+
+ /**
+ * @var TimeConverterInterface
+ */
+ private $timeConverter;
+
+ /**
+ * @var TimeProviderInterface
+ */
+ private $timeProvider;
+
+ /**
+ * Constructs a `TimeGeneratorFactory` using a node provider, time converter,
+ * and time provider
+ *
+ * @param NodeProviderInterface $nodeProvider
+ * @param TimeConverterInterface $timeConverter
+ * @param TimeProviderInterface $timeProvider
+ */
+ public function __construct(
+ NodeProviderInterface $nodeProvider,
+ TimeConverterInterface $timeConverter,
+ TimeProviderInterface $timeProvider
+ ) {
+ $this->nodeProvider = $nodeProvider;
+ $this->timeConverter = $timeConverter;
+ $this->timeProvider = $timeProvider;
+ }
+
+ /**
+ * Returns a default time generator, based on the current environment
+ *
+ * @return TimeGeneratorInterface
+ */
+ public function getGenerator()
+ {
+ return new DefaultTimeGenerator(
+ $this->nodeProvider,
+ $this->timeConverter,
+ $this->timeProvider
+ );
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Generator/TimeGeneratorInterface.php b/vendor/ramsey/uuid/src/Generator/TimeGeneratorInterface.php
new file mode 100644
index 0000000000..1a56d5131c
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Generator/TimeGeneratorInterface.php
@@ -0,0 +1,35 @@
+<?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\Generator;
+
+/**
+ * TimeGeneratorInterface provides functionality to generate strings of binary
+ * data for version 1 UUIDs based on a host ID, sequence number, and the current
+ * time
+ */
+interface TimeGeneratorInterface
+{
+ /**
+ * Generate a version 1 UUID from a host ID, sequence number, and the current time
+ *
+ * @param int|string $node A 48-bit number representing the hardware address
+ * This number may be represented as an integer or a hexadecimal string.
+ * @param int $clockSeq A 14-bit number used to help avoid duplicates that
+ * could arise when the clock is set backwards in time or if the node ID
+ * changes.
+ * @return string A binary string
+ */
+ public function generate($node = null, $clockSeq = null);
+}
diff --git a/vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php b/vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php
new file mode 100644
index 0000000000..e230e17a50
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php
@@ -0,0 +1,57 @@
+<?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\Provider\Node;
+
+use Ramsey\Uuid\Provider\NodeProviderInterface;
+
+/**
+ * FallbackNodeProvider attempts to gain the system host ID from an array of
+ * providers, falling back to the next in line in the event a host ID can not be
+ * obtained
+ */
+class FallbackNodeProvider implements NodeProviderInterface
+{
+ /**
+ * @var NodeProviderInterface[]
+ */
+ private $nodeProviders;
+
+ /**
+ * Constructs a `FallbackNodeProvider` using an array of node providers
+ *
+ * @param NodeProviderInterface[] $providers Array of node providers
+ */
+ public function __construct(array $providers)
+ {
+ $this->nodeProviders = $providers;
+ }
+
+ /**
+ * Returns the system node ID by iterating over an array of node providers
+ * and returning the first non-empty value found
+ *
+ * @return string System node ID as a hexadecimal string
+ */
+ public function getNode()
+ {
+ foreach ($this->nodeProviders as $provider) {
+ if ($node = $provider->getNode()) {
+ return $node;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php b/vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php
new file mode 100644
index 0000000000..6c81fdf5d7
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php
@@ -0,0 +1,36 @@
+<?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\Provider\Node;
+
+use Ramsey\Uuid\Provider\NodeProviderInterface;
+
+/**
+ * RandomNodeProvider provides functionality to generate a random node ID, in
+ * the event that the node ID could not be obtained from the host system
+ *
+ * @link http://tools.ietf.org/html/rfc4122#section-4.5
+ */
+class RandomNodeProvider implements NodeProviderInterface
+{
+ /**
+ * Returns the system node ID
+ *
+ * @return string System node ID as a hexadecimal string
+ */
+ public function getNode()
+ {
+ return sprintf('%06x%06x', mt_rand(0, 0xffffff), mt_rand(0, 0xffffff));
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php b/vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php
new file mode 100644
index 0000000000..216d7396b1
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php
@@ -0,0 +1,76 @@
+<?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\Provider\Node;
+
+use Ramsey\Uuid\Provider\NodeProviderInterface;
+
+/**
+ * SystemNodeProvider provides functionality to get the system node ID (MAC
+ * address) using external system calls
+ */
+class SystemNodeProvider implements NodeProviderInterface
+{
+ /**
+ * Returns the system node ID
+ *
+ * @return string|false System node ID as a hexadecimal string, or false if it is not found
+ */
+ public function getNode()
+ {
+ static $node = null;
+
+ if ($node !== null) {
+ return $node;
+ }
+
+ $pattern = '/[^:]([0-9A-Fa-f]{2}([:-])[0-9A-Fa-f]{2}(\2[0-9A-Fa-f]{2}){4})[^:]/';
+ $matches = array();
+
+ // Search the ifconfig output for all MAC addresses and return
+ // the first one found
+ $node = false;
+ if (preg_match_all($pattern, $this->getIfconfig(), $matches, PREG_PATTERN_ORDER)) {
+ $node = $matches[1][0];
+ $node = str_replace([':', '-'], '', $node);
+ }
+
+ return $node;
+ }
+
+ /**
+ * Returns the network interface configuration for the system
+ *
+ * @codeCoverageIgnore
+ * @return string
+ */
+ protected function getIfconfig()
+ {
+ ob_start();
+ switch (strtoupper(substr(php_uname('a'), 0, 3))) {
+ case 'WIN':
+ passthru('ipconfig /all 2>&1');
+ break;
+ case 'DAR':
+ passthru('ifconfig 2>&1');
+ break;
+ case 'LIN':
+ default:
+ passthru('netstat -ie 2>&1');
+ break;
+ }
+
+ return ob_get_clean();
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Provider/NodeProviderInterface.php b/vendor/ramsey/uuid/src/Provider/NodeProviderInterface.php
new file mode 100644
index 0000000000..864e8404fd
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Provider/NodeProviderInterface.php
@@ -0,0 +1,29 @@
+<?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\Provider;
+
+/**
+ * NodeProviderInterface provides functionality to get the node ID (or host ID
+ * in the form of the system's MAC address) from a specific type of node provider
+ */
+interface NodeProviderInterface
+{
+ /**
+ * Returns the system node ID
+ *
+ * @return string System node ID as a hexadecimal string
+ */
+ public function getNode();
+}
diff --git a/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php b/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php
new file mode 100644
index 0000000000..a62d39c626
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php
@@ -0,0 +1,76 @@
+<?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\Provider\Time;
+
+use Ramsey\Uuid\Provider\TimeProviderInterface;
+
+/**
+ * FixedTimeProvider uses an previously-generated timestamp to provide the time
+ *
+ * This provider allows the use of a previously-generated timestamp, such as one
+ * stored in a database, when creating version 1 UUIDs.
+ */
+class FixedTimeProvider implements TimeProviderInterface
+{
+ /**
+ * @var int[] Array containing `sec` and `usec` components of a timestamp
+ */
+ private $fixedTime;
+
+ /**
+ * Constructs a `FixedTimeProvider` using the provided `$timestamp`
+ *
+ * @param int[] Array containing `sec` and `usec` components of a timestamp
+ * @throws \InvalidArgumentException if the `$timestamp` does not contain `sec` or `usec` components
+ */
+ public function __construct(array $timestamp)
+ {
+ if (!array_key_exists('sec', $timestamp) || !array_key_exists('usec', $timestamp)) {
+ throw new \InvalidArgumentException('Array must contain sec and usec keys.');
+ }
+
+ $this->fixedTime = $timestamp;
+ }
+
+ /**
+ * Sets the `usec` component of the timestamp
+ *
+ * @param int $value The `usec` value to set
+ */
+ public function setUsec($value)
+ {
+ $this->fixedTime['usec'] = $value;
+ }
+
+ /**
+ * Sets the `sec` component of the timestamp
+ *
+ * @param int $value The `sec` value to set
+ */
+ public function setSec($value)
+ {
+ $this->fixedTime['sec'] = $value;
+ }
+
+ /**
+ * Returns a timestamp array
+ *
+ * @return int[] Array containing `sec` and `usec` components of a timestamp
+ */
+ public function currentTime()
+ {
+ return $this->fixedTime;
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Provider/Time/SystemTimeProvider.php b/vendor/ramsey/uuid/src/Provider/Time/SystemTimeProvider.php
new file mode 100644
index 0000000000..6442985fa7
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Provider/Time/SystemTimeProvider.php
@@ -0,0 +1,33 @@
+<?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\Provider\Time;
+
+use Ramsey\Uuid\Provider\TimeProviderInterface;
+
+/**
+ * SystemTimeProvider uses built-in PHP functions to provide the time
+ */
+class SystemTimeProvider implements TimeProviderInterface
+{
+ /**
+ * Returns a timestamp array
+ *
+ * @return int[] Array containing `sec` and `usec` components of a timestamp
+ */
+ public function currentTime()
+ {
+ return gettimeofday();
+ }
+}
diff --git a/vendor/ramsey/uuid/src/Provider/TimeProviderInterface.php b/vendor/ramsey/uuid/src/Provider/TimeProviderInterface.php
new file mode 100644
index 0000000000..ef8099dd14
--- /dev/null
+++ b/vendor/ramsey/uuid/src/Provider/TimeProviderInterface.php
@@ -0,0 +1,29 @@
+<?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\Provider;
+
+/**
+ * TimeProviderInterface provides functionality to get the time from a specific
+ * type of time provider
+ */
+interface TimeProviderInterface
+{
+ /**
+ * Returns a timestamp array
+ *
+ * @return int[] Array guaranteed to contain `sec` and `usec` components of a timestamp
+ */
+ public function currentTime();
+}
diff --git a/vendor/ramsey/uuid/src/Uuid.php b/vendor/ramsey/uuid/src/Uuid.php
index 7c8b814943..241dac4fdb 100644
--- a/vendor/ramsey/uuid/src/Uuid.php
+++ b/vendor/ramsey/uuid/src/Uuid.php
@@ -1,20 +1,25 @@
<?php
/**
- * This file is part of the Rhumsaa\Uuid library
+ * 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) 2013-2014 Ben Ramsey <http://benramsey.com>
+ * @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 Rhumsaa\Uuid;
+namespace Ramsey\Uuid;
-use InvalidArgumentException;
+use Ramsey\Uuid\Converter\NumberConverterInterface;
+use Ramsey\Uuid\Codec\CodecInterface;
+use Ramsey\Uuid\Exception\UnsupportedOperationException;
/**
- * Represents a universally unique identifier (UUID), according to RFC 4122
+ * Represents a universally unique identifier (UUID), according to RFC 4122.
*
* This class provides immutable UUID objects (the Uuid class) and the static
* methods `uuid1()`, `uuid3()`, `uuid4()`, and `uuid5()` for generating version
@@ -29,7 +34,7 @@ use InvalidArgumentException;
* @link http://docs.python.org/3/library/uuid.html
* @link http://docs.oracle.com/javase/6/docs/api/java/util/UUID.html
*/
-final class Uuid
+class Uuid implements UuidInterface
{
/**
* When this namespace is specified, the name string is a fully-qualified domain name.
@@ -91,54 +96,24 @@ final class Uuid
const VALID_PATTERN = '^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$';
/**
- * Version of the Rhumsaa\Uuid package
+ * The factory to use when creating UUIDs.
+ * @var UuidFactoryInterface
*/
- const VERSION = '2.8.3';
+ private static $factory = null;
/**
- * For testing, 64-bit system override; if true, treat the system as 32-bit
- *
- * @var bool
- */
- public static $force32Bit = false;
-
- /**
- * For testing, Moontoast\Math\BigNumber override; if true, treat as if
- * BigNumber is not available
- *
- * @var bool
+ * The codec to use when encoding or decoding UUID strings.
+ * @var CodecInterface
*/
- public static $forceNoBigNumber = false;
+ protected $codec;
/**
- * For testing, random_bytes() override; if true, treat as
- * if random_bytes() is not available
- *
- * @var bool
- */
- public static $forceNoRandomBytes = false;
-
- /**
- * For testing, sets time of day to a static, known value
- *
- * @var array
- */
- public static $timeOfDayTest;
-
- /**
- * For testing, system override to ignore generating node from hardware
- *
- * @var bool
- */
- public static $ignoreSystemNode = false;
-
- /**
- * The fields that make up this UUID
+ * The fields that make up this UUID.
*
* This is initialized to the nil value.
*
* @var array
- * @link Rhumsaa.Uuid.Uuid.html#method_getFields
+ * @see UuidInterface::getFieldsHex()
*/
protected $fields = array(
'time_low' => '00000000',
@@ -150,22 +125,47 @@ final class Uuid
);
/**
+ * The number converter to use for converting hex values to/from integers.
+ * @var NumberConverterInterface
+ */
+ protected $converter;
+
+ /**
* Creates a universally unique identifier (UUID) from an array of fields.
*
- * Protected to prevent direct instantiation. Use static methods to create
- * UUIDs.
+ * Unless you're making advanced use of this library to generate identifiers
+ * that deviate from RFC 4122, you probably do not want to instantiate a
+ * UUID directly. Use the static methods, instead:
*
- * @param array $fields
- * @link Rhumsaa.Uuid.Uuid.html#method_getFields
+ * ```
+ * use Ramsey\Uuid\Uuid;
+ *
+ * $timeBasedUuid = Uuid::uuid1();
+ * $namespaceMd5Uuid = Uuid::uuid3(Uuid::NAMESPACE_URL, 'http://php.net/');
+ * $randomUuid = Uuid::uuid4();
+ * $namespaceSha1Uuid = Uuid::uuid5(Uuid::NAMESPACE_URL, 'http://php.net/');
+ * ```
+ *
+ * @param array $fields An array of fields from which to construct a UUID;
+ * see {@see \Ramsey\Uuid\UuidInterface::getFieldsHex()} for array structure.
+ * @param NumberConverterInterface $converter The number converter to use
+ * for converting hex values to/from integers.
+ * @param CodecInterface $codec The codec to use when encoding or decoding
+ * UUID strings.
*/
- protected function __construct(array $fields)
- {
+ public function __construct(
+ array $fields,
+ NumberConverterInterface $converter,
+ CodecInterface $codec
+ ) {
$this->fields = $fields;
+ $this->codec = $codec;
+ $this->converter = $converter;
}
/**
* Converts this UUID object to a string when the object is used in any
- * string context
+ * string context.
*
* @return string
* @link http://www.php.net/manual/en/language.oop5.magic.php#object.tostring
@@ -176,71 +176,72 @@ final class Uuid
}
/**
- * Compares this UUID with the specified UUID.
+ * Converts this UUID object to a string when the object is serialized
+ * with `json_encode()`
*
- * The first of two UUIDs is greater than the second if the most
- * significant field in which the UUIDs differ is greater for the first
- * UUID.
+ * @return string
+ * @link http://php.net/manual/en/class.jsonserializable.php
+ */
+ public function jsonSerialize()
+ {
+ return $this->toString();
+ }
+
+ /**
+ * Converts this UUID object to a string when the object is serialized
+ * with `serialize()`
*
- * Q. What's the value of being able to sort UUIDs?<br>
- * A. Use them as keys in a B-Tree or similar mapping.
+ * @return string
+ * @link http://php.net/manual/en/class.serializable.php
+ */
+ public function serialize()
+ {
+ return $this->toString();
+ }
+
+ /**
+ * Re-constructs the object from its serialized form.
*
- * @param Uuid $uuid UUID to which this UUID is to be compared
- * @return int -1, 0 or 1 as this UUID is less than, equal to, or greater than $uuid
+ * @param string $serialized
+ * @link http://php.net/manual/en/class.serializable.php
*/
- public function compareTo(Uuid $uuid)
+ public function unserialize($serialized)
+ {
+ $uuid = self::fromString($serialized);
+ $this->codec = $uuid->codec;
+ $this->converter = $uuid->converter;
+ $this->fields = $uuid->fields;
+ }
+
+ public function compareTo(UuidInterface $other)
{
- $comparison = null;
+ $comparison = 0;
- if ($this->getMostSignificantBitsHex() < $uuid->getMostSignificantBitsHex()) {
+ if ($this->getMostSignificantBitsHex() < $other->getMostSignificantBitsHex()) {
$comparison = -1;
- } elseif ($this->getMostSignificantBitsHex() > $uuid->getMostSignificantBitsHex()) {
+ } elseif ($this->getMostSignificantBitsHex() > $other->getMostSignificantBitsHex()) {
$comparison = 1;
- } elseif ($this->getLeastSignificantBitsHex() < $uuid->getLeastSignificantBitsHex()) {
+ } elseif ($this->getLeastSignificantBitsHex() < $other->getLeastSignificantBitsHex()) {
$comparison = -1;
- } elseif ($this->getLeastSignificantBitsHex() > $uuid->getLeastSignificantBitsHex()) {
+ } elseif ($this->getLeastSignificantBitsHex() > $other->getLeastSignificantBitsHex()) {
$comparison = 1;
- } else {
- $comparison = 0;
}
return $comparison;
}
- /**
- * Compares this object to the specified object.
- *
- * The result is true if and only if the argument is not null, is a UUID
- * object, has the same variant, and contains the same value, bit for bit,
- * as this UUID.
- *
- * @param object $obj
- * @return bool True if $obj is equal to this UUID
- */
- public function equals($obj)
+ public function equals($other)
{
- if (!($obj instanceof Uuid)) {
+ if (!($other instanceof UuidInterface)) {
return false;
}
- return ($this->compareTo($obj) == 0);
+ return ($this->compareTo($other) == 0);
}
- /**
- * Returns the UUID as a 16-byte string (containing the six integer fields
- * in big-endian byte order)
- *
- * @return string
- */
public function getBytes()
{
- $bytes = '';
-
- foreach (range(-2, -32, 2) as $step) {
- $bytes = chr(hexdec(substr($this->getHex(), $step, 2))) . $bytes;
- }
-
- return $bytes;
+ return $this->codec->encodeBinary($this);
}
/**
@@ -254,12 +255,6 @@ final class Uuid
return hexdec($this->getClockSeqHiAndReservedHex());
}
- /**
- * Returns the high field of the clock sequence multiplexed with the variant
- * (bits 65-72 of the UUID).
- *
- * @return string Hexadecimal value of clock_seq_hi_and_reserved
- */
public function getClockSeqHiAndReservedHex()
{
return $this->fields['clock_seq_hi_and_reserved'];
@@ -275,11 +270,6 @@ final class Uuid
return hexdec($this->getClockSeqLowHex());
}
- /**
- * Returns the low field of the clock sequence (bits 73-80 of the UUID).
- *
- * @return string Hexadecimal value of clock_seq_low
- */
public function getClockSeqLowHex()
{
return $this->fields['clock_seq_low'];
@@ -307,52 +297,24 @@ final class Uuid
| $this->getClockSeqLow();
}
- /**
- * Returns the clock sequence value associated with this UUID.
- *
- * @return string Hexadecimal value of clock sequence
- */
public function getClockSequenceHex()
{
return sprintf('%04x', $this->getClockSequence());
}
- /**
- * Returns a PHP DateTime object representing the timestamp associated
- * with this UUID.
- *
- * The timestamp value is only meaningful in a time-based UUID, which
- * has version type 1. If this UUID is not a time-based UUID then
- * this method throws UnsupportedOperationException.
- *
- * @return \DateTime A PHP DateTime representation of the date
- * @throws Exception\UnsupportedOperationException If this UUID is not a version 1 UUID
- * @throws Exception\UnsatisfiedDependencyException if called on a 32-bit system
- * and Moontoast\Math\BigNumber is not present
- */
+ public function getNumberConverter()
+ {
+ return $this->converter;
+ }
+
public function getDateTime()
{
if ($this->getVersion() != 1) {
- throw new Exception\UnsupportedOperationException('Not a time-based UUID');
+ throw new UnsupportedOperationException('Not a time-based UUID');
}
- if (self::is64BitSystem()) {
- $unixTime = ($this->getTimestamp() - 0x01b21dd213814000) / 1e7;
- $unixTime = number_format($unixTime, 0, '', '');
- } elseif (self::hasBigNumber()) {
- $time = \Moontoast\Math\BigNumber::baseConvert($this->getTimestampHex(), 16, 10);
- $ts = new \Moontoast\Math\BigNumber($time, 20);
- $ts->subtract('122192928000000000');
- $ts->divide('10000000.0');
- $ts->round();
- $unixTime = $ts->getValue();
- } else {
- throw new Exception\UnsatisfiedDependencyException(
- 'When calling ' . __METHOD__ . ' on a 32-bit system, '
- . 'Moontoast\Math\BigNumber must be present in order '
- . 'to extract DateTime from version 1 UUIDs'
- );
- }
+ $unixTime = ($this->getTimestamp() - 0x01b21dd213814000) / 1e7;
+ $unixTime = number_format($unixTime, 0, '', '');
return new \DateTime("@{$unixTime}");
}
@@ -373,19 +335,10 @@ final class Uuid
* integer
*
* @return array The UUID fields represented as integer values
- * @throws Exception\UnsatisfiedDependencyException if called on a 32-bit system
* @link http://tools.ietf.org/html/rfc4122#section-4.1.2
*/
public function getFields()
{
- if (!self::is64BitSystem()) {
- throw new Exception\UnsatisfiedDependencyException(
- 'Cannot call ' . __METHOD__ . ' on a 32-bit system, since some '
- . 'values overflow the system max integer value'
- . '; consider calling getFieldsHex instead'
- );
- }
-
return array(
'time_low' => $this->getTimeLow(),
'time_mid' => $this->getTimeMid(),
@@ -396,95 +349,31 @@ final class Uuid
);
}
- /**
- * Returns an array of the fields of this UUID, with keys named according
- * to the RFC 4122 names for the fields.
- *
- * * **time_low**: The low field of the timestamp, an unsigned 32-bit integer
- * * **time_mid**: The middle field of the timestamp, an unsigned 16-bit integer
- * * **time_hi_and_version**: The high field of the timestamp multiplexed with
- * the version number, an unsigned 16-bit integer
- * * **clock_seq_hi_and_reserved**: The high field of the clock sequence
- * multiplexed with the variant, an unsigned 8-bit integer
- * * **clock_seq_low**: The low field of the clock sequence, an unsigned
- * 8-bit integer
- * * **node**: The spatially unique node identifier, an unsigned 48-bit
- * integer
- *
- * @return array The UUID fields represented as hexadecimal values
- */
public function getFieldsHex()
{
return $this->fields;
}
- /**
- * Returns the hexadecimal value of the UUID
- *
- * @return string
- */
public function getHex()
{
return str_replace('-', '', $this->toString());
}
- /**
- * Returns the integer value of the UUID, represented as a BigNumber
- *
- * @return \Moontoast\Math\BigNumber BigNumber representation of the unsigned 128-bit integer value
- * @throws Exception\UnsatisfiedDependencyException if Moontoast\Math\BigNumber is not present
- */
public function getInteger()
{
- if (!self::hasBigNumber()) {
- throw new Exception\UnsatisfiedDependencyException(
- 'Cannot call ' . __METHOD__ . ' without support for large '
- . 'integers, since integer is an unsigned '
- . '128-bit integer; Moontoast\Math\BigNumber is required'
- . '; consider calling getHex instead'
- );
- }
-
- $number = \Moontoast\Math\BigNumber::baseConvert(
- $this->getHex(),
- 16,
- 10
- );
-
- return new \Moontoast\Math\BigNumber($number);
+ return $this->converter->fromHex($this->getHex());
}
/**
- * Returns the least significant 64 bits of this UUID's 128 bit value
+ * Returns the least significant 64 bits of this UUID's 128 bit value.
*
- * @return \Moontoast\Math\BigNumber BigNumber representation of the unsigned 64-bit integer value
- * @throws Exception\UnsatisfiedDependencyException if Moontoast\Math\BigNumber is not present
+ * @return mixed Converted representation of the unsigned 64-bit integer value
*/
public function getLeastSignificantBits()
{
- if (!self::hasBigNumber()) {
- throw new Exception\UnsatisfiedDependencyException(
- 'Cannot call ' . __METHOD__ . ' without support for large '
- . 'integers, since least significant bits is an unsigned '
- . '64-bit integer; Moontoast\Math\BigNumber is required'
- . '; consider calling getLeastSignificantBitsHex instead'
- );
- }
-
- $number = \Moontoast\Math\BigNumber::baseConvert(
- $this->getLeastSignificantBitsHex(),
- 16,
- 10
- );
-
- return new \Moontoast\Math\BigNumber($number);
+ return $this->converter->fromHex($this->getLeastSignificantBitsHex());
}
- /**
- * Returns the least significant 64 bits of this UUID's 128 bit value
- *
- * @return string Hexadecimal value of least significant bits
- */
public function getLeastSignificantBitsHex()
{
return sprintf(
@@ -496,36 +385,15 @@ final class Uuid
}
/**
- * Returns the most significant 64 bits of this UUID's 128 bit value
+ * Returns the most significant 64 bits of this UUID's 128 bit value.
*
- * @return \Moontoast\Math\BigNumber BigNumber representation of the unsigned 64-bit integer value
- * @throws Exception\UnsatisfiedDependencyException if Moontoast\Math\BigNumber is not present
+ * @return mixed Converted representation of the unsigned 64-bit integer value
*/
public function getMostSignificantBits()
{
- if (!self::hasBigNumber()) {
- throw new Exception\UnsatisfiedDependencyException(
- 'Cannot call ' . __METHOD__ . ' without support for large '
- . 'integers, since most significant bits is an unsigned '
- . '64-bit integer; Moontoast\Math\BigNumber is required'
- . '; consider calling getMostSignificantBitsHex instead'
- );
- }
-
- $number = \Moontoast\Math\BigNumber::baseConvert(
- $this->getMostSignificantBitsHex(),
- 16,
- 10
- );
-
- return new \Moontoast\Math\BigNumber($number);
+ return $this->converter->fromHex($this->getMostSignificantBitsHex());
}
- /**
- * Returns the most significant 64 bits of this UUID's 128 bit value
- *
- * @return string Hexadecimal value of most significant bits
- */
public function getMostSignificantBitsHex()
{
return sprintf(
@@ -559,46 +427,12 @@ final class Uuid
*
* @return int Unsigned 48-bit integer value of node
* @link http://tools.ietf.org/html/rfc4122#section-4.1.6
- * @throws Exception\UnsatisfiedDependencyException if called on a 32-bit system
*/
public function getNode()
{
- if (!self::is64BitSystem()) {
- throw new Exception\UnsatisfiedDependencyException(
- 'Cannot call ' . __METHOD__ . ' on a 32-bit system, since node '
- . 'is an unsigned 48-bit integer and can overflow the system '
- . 'max integer value'
- . '; consider calling getNodeHex instead'
- );
- }
-
return hexdec($this->getNodeHex());
}
- /**
- * Returns the node value associated with this UUID
- *
- * For UUID version 1, the node field consists of an IEEE 802 MAC
- * address, usually the host address. For systems with multiple IEEE
- * 802 addresses, any available one can be used. The lowest addressed
- * octet (octet number 10) contains the global/local bit and the
- * unicast/multicast bit, and is the first octet of the address
- * transmitted on an 802.3 LAN.
- *
- * For systems with no IEEE address, a randomly or pseudo-randomly
- * generated value may be used; see RFC 4122, Section 4.5. The
- * multicast bit must be set in such addresses, in order that they
- * will never conflict with addresses obtained from network cards.
- *
- * For UUID version 3 or 5, the node field is a 48-bit value constructed
- * from a name as described in RFC 4122, Section 4.3.
- *
- * For UUID version 4, the node field is a randomly or pseudo-randomly
- * generated 48-bit value as described in RFC 4122, Section 4.4.
- *
- * @return string Hexadecimal value of node
- * @link http://tools.ietf.org/html/rfc4122#section-4.1.6
- */
public function getNodeHex()
{
return $this->fields['node'];
@@ -615,12 +449,6 @@ final class Uuid
return hexdec($this->getTimeHiAndVersionHex());
}
- /**
- * Returns the high field of the timestamp multiplexed with the version
- * number (bits 49-64 of the UUID).
- *
- * @return string Hexadecimal value of time_hi_and_version
- */
public function getTimeHiAndVersionHex()
{
return $this->fields['time_hi_and_version'];
@@ -630,27 +458,12 @@ final class Uuid
* Returns the low field of the timestamp (the first 32 bits of the UUID).
*
* @return int Unsigned 32-bit integer value of time_low
- * @throws Exception\UnsatisfiedDependencyException if called on a 32-bit system
*/
public function getTimeLow()
{
- if (!self::is64BitSystem()) {
- throw new Exception\UnsatisfiedDependencyException(
- 'Cannot call ' . __METHOD__ . ' on a 32-bit system, since time_low '
- . 'is an unsigned 32-bit integer and can overflow the system '
- . 'max integer value'
- . '; consider calling getTimeLowHex instead'
- );
- }
-
return hexdec($this->getTimeLowHex());
}
- /**
- * Returns the low field of the timestamp (the first 32 bits of the UUID).
- *
- * @return string Hexadecimal value of time_low
- */
public function getTimeLowHex()
{
return $this->fields['time_low'];
@@ -666,18 +479,13 @@ final class Uuid
return hexdec($this->getTimeMidHex());
}
- /**
- * Returns the middle field of the timestamp (bits 33-48 of the UUID).
- *
- * @return string Hexadecimal value of time_mid
- */
public function getTimeMidHex()
{
return $this->fields['time_mid'];
}
/**
- * The timestamp value associated with this UUID
+ * Returns the timestamp value associated with this UUID.
*
* The 60 bit timestamp value is constructed from the time_low,
* time_mid, and time_hi fields of this UUID. The resulting
@@ -689,48 +497,22 @@ final class Uuid
* this method throws UnsupportedOperationException.
*
* @return int Unsigned 60-bit integer value of the timestamp
- * @throws Exception\UnsupportedOperationException If this UUID is not a version 1 UUID
- * @throws Exception\UnsatisfiedDependencyException if called on a 32-bit system
+ * @throws UnsupportedOperationException If this UUID is not a version 1 UUID
* @link http://tools.ietf.org/html/rfc4122#section-4.1.4
*/
public function getTimestamp()
{
if ($this->getVersion() != 1) {
- throw new Exception\UnsupportedOperationException('Not a time-based UUID');
- }
-
- if (!self::is64BitSystem()) {
- throw new Exception\UnsatisfiedDependencyException(
- 'Cannot call ' . __METHOD__ . ' on a 32-bit system, since timestamp '
- . 'is an unsigned 60-bit integer and can overflow the system '
- . 'max integer value'
- . '; consider calling getTimestampHex instead'
- );
+ throw new UnsupportedOperationException('Not a time-based UUID');
}
return hexdec($this->getTimestampHex());
}
- /**
- * The timestamp value associated with this UUID
- *
- * The 60 bit timestamp value is constructed from the time_low,
- * time_mid, and time_hi fields of this UUID. The resulting
- * timestamp is measured in 100-nanosecond units since midnight,
- * October 15, 1582 UTC.
- *
- * The timestamp value is only meaningful in a time-based UUID, which
- * has version type 1. If this UUID is not a time-based UUID then
- * this method throws UnsupportedOperationException.
- *
- * @return string Hexadecimal value of the timestamp
- * @throws Exception\UnsupportedOperationException If this UUID is not a version 1 UUID
- * @link http://tools.ietf.org/html/rfc4122#section-4.1.4
- */
public function getTimestampHex()
{
if ($this->getVersion() != 1) {
- throw new Exception\UnsupportedOperationException('Not a time-based UUID');
+ throw new UnsupportedOperationException('Not a time-based UUID');
}
return sprintf(
@@ -741,31 +523,11 @@ final class Uuid
);
}
- /**
- * Returns the string representation of the UUID as a URN.
- *
- * @return string
- * @link http://en.wikipedia.org/wiki/Uniform_Resource_Name
- */
public function getUrn()
{
return 'urn:uuid:' . $this->toString();
}
- /**
- * Returns the variant number associated with this UUID.
- *
- * The variant number describes the layout of the UUID. The variant
- * number has the following meaning:
- *
- * * 0 - Reserved for NCS backward compatibility
- * * 2 - The RFC 4122 variant (used by this class)
- * * 6 - Reserved, Microsoft Corporation backward compatibility
- * * 7 - Reserved for future definition
- *
- * @return int
- * @link http://tools.ietf.org/html/rfc4122#section-4.1.1
- */
public function getVariant()
{
$clockSeq = $this->getClockSeqHiAndReserved();
@@ -782,24 +544,6 @@ final class Uuid
return $variant;
}
- /**
- * The version number associated with this UUID. The version
- * number describes how this UUID was generated.
- *
- * The version number has the following meaning:
- *
- * * 1 - Time-based UUID
- * * 2 - DCE security UUID
- * * 3 - Name-based UUID hashed with MD5
- * * 4 - Randomly generated UUID
- * * 5 - Name-based UUID hashed with SHA-1
- *
- * Returns null if this UUID is not an RFC 4122 variant, since version
- * is only meaningful for this variant.
- *
- * @return int|null
- * @link http://tools.ietf.org/html/rfc4122#section-4.1.3
- */
public function getVersion()
{
if ($this->getVariant() == self::RFC_4122) {
@@ -809,115 +553,72 @@ final class Uuid
return null;
}
+ public function toString()
+ {
+ return $this->codec->encode($this);
+ }
+
/**
- * Converts this UUID into a string representation
+ * Returns the currently set factory used to create UUIDs.
*
- * @return string
+ * @return UuidFactoryInterface
*/
- public function toString()
+ public static function getFactory()
{
- return vsprintf(
- '%08s-%04s-%04s-%02s%02s-%012s',
- $this->fields
- );
+ if (!self::$factory) {
+ self::$factory = new UuidFactory();
+ }
+
+ return self::$factory;
+ }
+
+ /**
+ * Sets the factory used to create UUIDs.
+ *
+ * @param UuidFactoryInterface $factory
+ */
+ public static function setFactory(UuidFactoryInterface $factory)
+ {
+ self::$factory = $factory;
}
/**
* Creates a UUID from a byte string.
*
* @param string $bytes
- * @return Uuid
- * @throws InvalidArgumentException If the $bytes string does not contain 16 characters
+ * @return UuidInterface
*/
public static function fromBytes($bytes)
{
- if (strlen($bytes) !== 16) {
- throw new InvalidArgumentException('$bytes string should contain 16 characters.');
- }
-
- $uuid = '';
- foreach (range(0, 15) as $step) {
- $uuid .= sprintf('%02x', ord($bytes[$step]));
-
- if (in_array($step, array(3, 5, 7, 9))) {
- $uuid .= '-';
- }
- }
-
- return Uuid::fromString($uuid);
+ return self::getFactory()->fromBytes($bytes);
}
/**
- * Creates a UUID from the string standard representation as described
- * in the toString() method.
+ * Creates a UUID from the string standard representation.
*
* @param string $name A string that specifies a UUID
- * @return Uuid
- * @throws InvalidArgumentException If the $name isn't a valid UUID
+ * @return UuidInterface
*/
public static function fromString($name)
{
- $nameParsed = str_replace(array('urn:', 'uuid:', '{', '}', '-'), '', $name);
-
- // We have stripped out the dashes and are breaking up the string using
- // substr(). In this way, we can accept a full hex value that doesn't
- // contain dashes.
- $components = array(
- substr($nameParsed, 0, 8),
- substr($nameParsed, 8, 4),
- substr($nameParsed, 12, 4),
- substr($nameParsed, 16, 4),
- substr($nameParsed, 20),
- );
- $nameParsed = implode('-', $components);
-
- if (!self::isValid($nameParsed)) {
- throw new InvalidArgumentException('Invalid UUID string: ' . $name);
- }
-
- $fields = array(
- 'time_low' => sprintf('%08s', $components[0]),
- 'time_mid' => sprintf('%04s', $components[1]),
- 'time_hi_and_version' => sprintf('%04s', $components[2]),
- 'clock_seq_hi_and_reserved' => sprintf('%02s', substr($components[3], 0, 2)),
- 'clock_seq_low' => sprintf('%02s', substr($components[3], 2)),
- 'node' => sprintf('%012s', $components[4]),
- );
-
- return new self($fields);
+ return self::getFactory()->fromString($name);
}
/**
- * Creates a UUID from either the UUID as a 128-bit integer string or a Moontoast\Math\BigNumber object.
+ * Creates a UUID from a 128-bit integer string.
*
- * @param string|\Moontoast\Math\BigNumber $integer String/BigNumber representation of UUID integer
- * @throws Exception\UnsatisfiedDependencyException If Moontoast\Math\BigNumber is not present
- * @return \Rhumsaa\Uuid\Uuid
+ * @param string $integer String representation of 128-bit integer
+ * @return UuidInterface
*/
public static function fromInteger($integer)
{
- if (!self::hasBigNumber()) {
- throw new Exception\UnsatisfiedDependencyException(
- 'Cannot call ' . __METHOD__ . ' without support for large '
- . 'integers, since integer is an unsigned '
- . '128-bit integer; Moontoast\Math\BigNumber is required. '
- );
- }
-
- if (!$integer instanceof \Moontoast\Math\BigNumber) {
- $integer = new \Moontoast\Math\BigNumber($integer);
- }
-
- $hex = \Moontoast\Math\BigNumber::baseConvert($integer, 10, 16);
- $hex = str_pad($hex, 32, '0', STR_PAD_LEFT);
-
- return self::fromString($hex);
+ return self::getFactory()->fromInteger($integer);
}
/**
- * Check if a string is a valid uuid
+ * Check if a string is a valid UUID.
*
- * @param string $uuid The uuid to test
+ * @param string $uuid The string UUID to test
* @return boolean
*/
public static function isValid($uuid)
@@ -931,328 +632,58 @@ final class Uuid
if (!preg_match('/' . self::VALID_PATTERN . '/', $uuid)) {
return false;
}
+
return true;
}
/**
* Generate a version 1 UUID from a host ID, sequence number, and the current time.
- * If $node is not given, we will attempt to obtain the local hardware
- * address. If $clockSeq is given, it is used as the sequence number;
- * otherwise a random 14-bit sequence number is chosen.
*
- * @param int|string $node A 48-bit number representing the hardware
- * address. This number may be represented as
- * an integer or a hexadecimal string.
+ * @param int|string $node A 48-bit number representing the hardware address
+ * This number may be represented as an integer or a hexadecimal string.
* @param int $clockSeq A 14-bit number used to help avoid duplicates that
- * could arise when the clock is set backwards in time
- * or if the node ID changes.
- * @return Uuid
- * @throws InvalidArgumentException if the $node is invalid
+ * could arise when the clock is set backwards in time or if the node ID
+ * changes.
+ * @return UuidInterface
*/
public static function uuid1($node = null, $clockSeq = null)
{
- if ($node === null && !self::$ignoreSystemNode) {
- $node = self::getNodeFromSystem();
- }
-
- // if $node is still null (couldn't get from system), randomly generate
- // a node value, according to RFC 4122, Section 4.5
- if ($node === null) {
- $node = sprintf('%06x%06x', mt_rand(0, 1 << 24), mt_rand(0, 1 << 24));
- }
-
- // Convert the node to hex, if it is still an integer
- if (is_int($node)) {
- $node = sprintf('%012x', $node);
- }
-
- if (ctype_xdigit($node) && strlen($node) <= 12) {
- $node = strtolower(sprintf('%012s', $node));
- } else {
- throw new InvalidArgumentException('Invalid node value');
- }
-
- if ($clockSeq === null) {
- // Not using "stable storage"; see RFC 4122, Section 4.2.1.1
- $clockSeq = mt_rand(0, 1 << 14);
- }
-
- // Create a 60-bit time value as a count of 100-nanosecond intervals
- // since 00:00:00.00, 15 October 1582
- if (self::$timeOfDayTest === null) {
- $timeOfDay = gettimeofday();
- } else {
- $timeOfDay = self::$timeOfDayTest;
- }
- $uuidTime = self::calculateUuidTime($timeOfDay['sec'], $timeOfDay['usec']);
-
- // Set the version number to 1
- $timeHi = hexdec($uuidTime['hi']) & 0x0fff;
- $timeHi &= ~(0xf000);
- $timeHi |= 1 << 12;
-
- // Set the variant to RFC 4122
- $clockSeqHi = ($clockSeq >> 8) & 0x3f;
- $clockSeqHi &= ~(0xc0);
- $clockSeqHi |= 0x80;
-
- $fields = array(
- 'time_low' => $uuidTime['low'],
- 'time_mid' => $uuidTime['mid'],
- 'time_hi_and_version' => sprintf('%04x', $timeHi),
- 'clock_seq_hi_and_reserved' => sprintf('%02x', $clockSeqHi),
- 'clock_seq_low' => sprintf('%02x', $clockSeq & 0xff),
- 'node' => $node,
- );
-
- return new self($fields);
+ return self::getFactory()->uuid1($node, $clockSeq);
}
/**
- * Generate a version 3 UUID based on the MD5 hash of a namespace identifier (which
- * is a UUID) and a name (which is a string).
+ * Generate a version 3 UUID based on the MD5 hash of a namespace identifier
+ * (which is a UUID) and a name (which is a string).
*
- * @param Uuid|string $ns The UUID namespace in which to create the named UUID
+ * @param string $ns The UUID namespace in which to create the named UUID
* @param string $name The name to create a UUID for
- * @return Uuid
+ * @return UuidInterface
*/
public static function uuid3($ns, $name)
{
- if (!($ns instanceof Uuid)) {
- $ns = self::fromString($ns);
- }
-
- $hash = md5($ns->getBytes() . $name);
-
- return self::uuidFromHashedName($hash, 3);
+ return self::getFactory()->uuid3($ns, $name);
}
/**
* Generate a version 4 (random) UUID.
*
- * @return Uuid
+ * @return UuidInterface
*/
public static function uuid4()
{
- $bytes = self::generateBytes(16);
-
- // When converting the bytes to hex, it turns into a 32-character
- // hexadecimal string that looks a lot like an MD5 hash, so at this
- // point, we can just pass it to uuidFromHashedName.
- $hex = bin2hex($bytes);
- return self::uuidFromHashedName($hex, 4);
+ return self::getFactory()->uuid4();
}
/**
- * Generate a version 5 UUID based on the SHA-1 hash of a namespace identifier (which
- * is a UUID) and a name (which is a string).
+ * Generate a version 5 UUID based on the SHA-1 hash of a namespace
+ * identifier (which is a UUID) and a name (which is a string).
*
- * @param Uuid|string $ns The UUID namespace in which to create the named UUID
+ * @param string $ns The UUID namespace in which to create the named UUID
* @param string $name The name to create a UUID for
- * @return Uuid
+ * @return UuidInterface
*/
public static function uuid5($ns, $name)
{
- if (!($ns instanceof Uuid)) {
- $ns = self::fromString($ns);
- }
-
- $hash = sha1($ns->getBytes() . $name);
-
- return self::uuidFromHashedName($hash, 5);
- }
-
- /**
- * Calculates the UUID time fields from a UNIX timestamp
- *
- * UUID time is a 60-bit time value as a count of 100-nanosecond intervals
- * since 00:00:00.00, 15 October 1582.
- *
- * @param int $sec Seconds since the Unix Epoch
- * @param int $usec Microseconds
- * @return array
- * @throws Exception\UnsatisfiedDependencyException if called on a 32-bit system
- * and Moontoast\Math\BigNumber is not present
- */
- protected static function calculateUuidTime($sec, $usec)
- {
- if (self::is64BitSystem()) {
- // 0x01b21dd213814000 is the number of 100-ns intervals between the
- // UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
- $uuidTime = ($sec * 10000000) + ($usec * 10) + 0x01b21dd213814000;
-
- return array(
- 'low' => sprintf('%08x', $uuidTime & 0xffffffff),
- 'mid' => sprintf('%04x', ($uuidTime >> 32) & 0xffff),
- 'hi' => sprintf('%04x', ($uuidTime >> 48) & 0x0fff),
- );
- }
-
- if (self::hasBigNumber()) {
- $uuidTime = new \Moontoast\Math\BigNumber('0');
-
- $sec = new \Moontoast\Math\BigNumber($sec);
- $sec->multiply('10000000');
-
- $usec = new \Moontoast\Math\BigNumber($usec);
- $usec->multiply('10');
-
- $uuidTime->add($sec)
- ->add($usec)
- ->add('122192928000000000');
-
- $uuidTimeHex = sprintf('%016s', $uuidTime->convertToBase(16));
-
- return array(
- 'low' => substr($uuidTimeHex, 8),
- 'mid' => substr($uuidTimeHex, 4, 4),
- 'hi' => substr($uuidTimeHex, 0, 4),
- );
- }
-
- throw new Exception\UnsatisfiedDependencyException(
- 'When calling ' . __METHOD__ . ' on a 32-bit system, '
- . 'Moontoast\Math\BigNumber must be present'
- );
- }
-
- /**
- * Returns the network interface configuration for the system
- *
- * @todo Needs evaluation and possibly modification to ensure this works
- * well across multiple platforms.
- * @codeCoverageIgnore
- */
- protected static function getIfconfig()
- {
- ob_start();
- switch (strtoupper(substr(php_uname('a'), 0, 3))) {
- case 'WIN':
- passthru('ipconfig /all 2>&1');
- break;
- case 'DAR':
- passthru('ifconfig 2>&1');
- break;
- case 'LIN':
- default:
- passthru('netstat -ie 2>&1');
- break;
- }
-
- return ob_get_clean();
- }
-
- /**
- * Get the hardware address as a 48-bit positive integer. If all attempts to
- * obtain the hardware address fail, we choose a random 48-bit number with
- * its eighth bit set to 1 as recommended in RFC 4122. "Hardware address"
- * means the MAC address of a network interface, and on a machine with
- * multiple network interfaces the MAC address of any one of them may be
- * returned.
- *
- * @return string
- */
- protected static function getNodeFromSystem()
- {
- static $node = null;
-
- if ($node !== null) {
- return $node;
- }
-
- $pattern = '/[^:]([0-9A-Fa-f]{2}([:-])[0-9A-Fa-f]{2}(\2[0-9A-Fa-f]{2}){4})[^:]/';
- $matches = array();
-
- // Search the ifconfig output for all MAC addresses and return
- // the first one found
- if (preg_match_all($pattern, self::getIfconfig(), $matches, PREG_PATTERN_ORDER)) {
- $node = $matches[1][0];
- $node = str_replace(':', '', $node);
- $node = str_replace('-', '', $node);
- }
-
- return $node;
- }
-
- /**
- * Returns true if the system has Moontoast\Math\BigNumber
- *
- * @return bool
- */
- protected static function hasBigNumber()
- {
- return (class_exists('Moontoast\Math\BigNumber') && !self::$forceNoBigNumber);
- }
-
- /**
- * Returns true if the system has random_bytes()
- *
- * @return bool
- */
- protected static function hasRandomBytes()
- {
- return (function_exists('random_bytes') && !self::$forceNoRandomBytes);
- }
-
- /**
- * Returns true if the system is 64-bit, false otherwise
- *
- * @return bool
- */
- protected static function is64BitSystem()
- {
- return (PHP_INT_SIZE == 8 && !self::$force32Bit);
- }
-
- /**
- * Returns a version 3 or 5 UUID based on the hash (md5 or sha1) of a
- * namespace identifier (which is a UUID) and a name (which is a string)
- *
- * @param string $hash The hash to use when creating the UUID
- * @param int $version The UUID version to be generated
- * @return Uuid
- */
- protected static function uuidFromHashedName($hash, $version)
- {
- // Set the version number
- $timeHi = hexdec(substr($hash, 12, 4)) & 0x0fff;
- $timeHi &= ~(0xf000);
- $timeHi |= $version << 12;
-
- // Set the variant to RFC 4122
- $clockSeqHi = hexdec(substr($hash, 16, 2)) & 0x3f;
- $clockSeqHi &= ~(0xc0);
- $clockSeqHi |= 0x80;
-
- $fields = array(
- 'time_low' => substr($hash, 0, 8),
- 'time_mid' => substr($hash, 8, 4),
- 'time_hi_and_version' => sprintf('%04x', $timeHi),
- 'clock_seq_hi_and_reserved' => sprintf('%02x', $clockSeqHi),
- 'clock_seq_low' => substr($hash, 18, 2),
- 'node' => substr($hash, 20, 12),
- );
-
- return new self($fields);
- }
-
- /**
- * Generates random bytes for use in version 4 UUIDs
- *
- * @param int $length
- * @return string
- */
- private static function generateBytes($length)
- {
- if (self::hasRandomBytes()) {
- return random_bytes($length);
- }
-
- $bytes = '';
- for ($i = 1; $i <= $length; $i++) {
- $bytes = chr(mt_rand(0, 255)) . $bytes;
- }
-
- return $bytes;
+ return self::getFactory()->uuid5($ns, $name);
}
}
diff --git a/vendor/ramsey/uuid/src/UuidFactory.php b/vendor/ramsey/uuid/src/UuidFactory.php
new file mode 100644
index 0000000000..77d2383c3a
--- /dev/null
+++ b/vendor/ramsey/uuid/src/UuidFactory.php
@@ -0,0 +1,292 @@
+<?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;
+
+use Ramsey\Uuid\Converter\NumberConverterInterface;
+use Ramsey\Uuid\Provider\NodeProviderInterface;
+use Ramsey\Uuid\Generator\RandomGeneratorInterface;
+use Ramsey\Uuid\Generator\TimeGeneratorInterface;
+use Ramsey\Uuid\Codec\CodecInterface;
+use Ramsey\Uuid\Builder\UuidBuilderInterface;
+
+class UuidFactory implements UuidFactoryInterface
+{
+ /**
+ * @var CodecInterface
+ */
+ private $codec = null;
+
+ /**
+ * @var NodeProviderInterface
+ */
+ private $nodeProvider = null;
+
+ /**
+ * @var NumberConverterInterface
+ */
+ private $numberConverter = null;
+
+ /**
+ * @var RandomGeneratorInterface
+ */
+ private $randomGenerator = null;
+
+ /**
+ * @var TimeGeneratorInterface
+ */
+ private $timeGenerator = null;
+
+ /**
+ * @var UuidBuilderInterface
+ */
+ private $uuidBuilder = null;
+
+ /**
+ * Constructs a `UuidFactory` for creating `Ramsey\Uuid\UuidInterface` instances
+ *
+ * @param FeatureSet $features A set of features for use when creating UUIDs
+ */
+ public function __construct(FeatureSet $features = null)
+ {
+ $features = $features ?: new FeatureSet();
+
+ $this->codec = $features->getCodec();
+ $this->nodeProvider = $features->getNodeProvider();
+ $this->numberConverter = $features->getNumberConverter();
+ $this->randomGenerator = $features->getRandomGenerator();
+ $this->timeGenerator = $features->getTimeGenerator();
+ $this->uuidBuilder = $features->getBuilder();
+ }
+
+ /**
+ * Returns the UUID coder-decoder used by this factory
+ *
+ * @return CodecInterface
+ */
+ public function getCodec()
+ {
+ return $this->codec;
+ }
+
+ /**
+ * Sets the UUID coder-decoder used by this factory
+ *
+ * @param CodecInterface $codec
+ */
+ public function setCodec(CodecInterface $codec)
+ {
+ $this->codec = $codec;
+ }
+
+ /**
+ * Returns the system node ID provider used by this factory
+ *
+ * @return NodeProviderInterface
+ */
+ public function getNodeProvider()
+ {
+ return $this->nodeProvider;
+ }
+
+ /**
+ * Returns the random UUID generator used by this factory
+ *
+ * @return RandomGeneratorInterface
+ */
+ public function getRandomGenerator()
+ {
+ return $this->randomGenerator;
+ }
+
+ /**
+ * Returns the time-based UUID generator used by this factory
+ *
+ * @return TimeGeneratorInterface
+ */
+ public function getTimeGenerator()
+ {
+ return $this->timeGenerator;
+ }
+
+ /**
+ * Sets the time-based UUID generator this factory will use to generate version 1 UUIDs
+ *
+ * @param TimeGeneratorInterface $generator
+ */
+ public function setTimeGenerator(TimeGeneratorInterface $generator)
+ {
+ $this->timeGenerator = $generator;
+ }
+
+ /**
+ * Returns the number converter used by this factory
+ *
+ * @return NumberConverterInterface
+ */
+ public function getNumberConverter()
+ {
+ return $this->numberConverter;
+ }
+
+ /**
+ * Sets the random UUID generator this factory will use to generate version 4 UUIDs
+ *
+ * @param RandomGeneratorInterface $generator
+ */
+ public function setRandomGenerator(RandomGeneratorInterface $generator)
+ {
+ $this->randomGenerator = $generator;
+ }
+
+ /**
+ * Sets the number converter this factory will use
+ *
+ * @param NumberConverterInterface $converter
+ */
+ public function setNumberConverter(NumberConverterInterface $converter)
+ {
+ $this->numberConverter = $converter;
+ }
+
+ /**
+ * Returns the UUID builder this factory uses when creating `Uuid` instances
+ *
+ * @return UuidBuilderInterface $builder
+ */
+ public function getUuidBuilder()
+ {
+ return $this->uuidBuilder;
+ }
+
+ /**
+ * Sets the UUID builder this factory will use when creating `Uuid` instances
+ *
+ * @param UuidBuilderInterface $builder
+ */
+ public function setUuidBuilder(UuidBuilderInterface $builder)
+ {
+ $this->uuidBuilder = $builder;
+ }
+
+ public function fromBytes($bytes)
+ {
+ return $this->codec->decodeBytes($bytes);
+ }
+
+ public function fromString($uuid)
+ {
+ $uuid = strtolower($uuid);
+ return $this->codec->decode($uuid);
+ }
+
+ public function fromInteger($integer)
+ {
+ $hex = $this->numberConverter->toHex($integer);
+ $hex = str_pad($hex, 32, '0', STR_PAD_LEFT);
+
+ return $this->fromString($hex);
+ }
+
+ public function uuid1($node = null, $clockSeq = null)
+ {
+ $bytes = $this->timeGenerator->generate($node, $clockSeq);
+ $hex = bin2hex($bytes);
+
+ return $this->uuidFromHashedName($hex, 1);
+ }
+
+ public function uuid3($ns, $name)
+ {
+ return $this->uuidFromNsAndName($ns, $name, 3, 'md5');
+ }
+
+ public function uuid4()
+ {
+ $bytes = $this->randomGenerator->generate(16);
+
+ // When converting the bytes to hex, it turns into a 32-character
+ // hexadecimal string that looks a lot like an MD5 hash, so at this
+ // point, we can just pass it to uuidFromHashedName.
+ $hex = bin2hex($bytes);
+
+ return $this->uuidFromHashedName($hex, 4);
+ }
+
+ public function uuid5($ns, $name)
+ {
+ return $this->uuidFromNsAndName($ns, $name, 5, 'sha1');
+ }
+
+ /**
+ * Returns a `Uuid`
+ *
+ * Uses the configured builder and codec and the provided array of hexadecimal
+ * value UUID fields to construct a `Uuid` object.
+ *
+ * @param array $fields An array of fields from which to construct a UUID;
+ * see {@see \Ramsey\Uuid\UuidInterface::getFieldsHex()} for array structure.
+ * @return UuidInterface
+ */
+ public function uuid(array $fields)
+ {
+ return $this->uuidBuilder->build($this->codec, $fields);
+ }
+
+ /**
+ * Returns a version 3 or 5 namespaced `Uuid`
+ *
+ * @param string|UuidInterface $ns The UUID namespace to use
+ * @param string $name The string to hash together with the namespace
+ * @param int $version The version of UUID to create (3 or 5)
+ * @param string $hashFunction The hash function to use when hashing together
+ * the namespace and name
+ * @return UuidInterface
+ */
+ protected function uuidFromNsAndName($ns, $name, $version, $hashFunction)
+ {
+ if (!($ns instanceof UuidInterface)) {
+ $ns = $this->codec->decode($ns);
+ }
+
+ $hash = call_user_func($hashFunction, ($ns->getBytes() . $name));
+
+ return $this->uuidFromHashedName($hash, $version);
+ }
+
+ /**
+ * Returns a `Uuid` created from `$hash` with the version field set to `$version`
+ * and the variant field set for RFC 4122
+ *
+ * @param string $hash The hash to use when creating the UUID
+ * @param int $version The UUID version to set for this hash (1, 3, 4, or 5)
+ * @return UuidInterface
+ */
+ protected function uuidFromHashedName($hash, $version)
+ {
+ $timeHi = BinaryUtils::applyVersion(substr($hash, 12, 4), $version);
+ $clockSeqHi = BinaryUtils::applyVariant(hexdec(substr($hash, 16, 2)));
+
+ $fields = array(
+ 'time_low' => substr($hash, 0, 8),
+ 'time_mid' => substr($hash, 8, 4),
+ 'time_hi_and_version' => str_pad(dechex($timeHi), 4, '0', STR_PAD_LEFT),
+ 'clock_seq_hi_and_reserved' => str_pad(dechex($clockSeqHi), 2, '0', STR_PAD_LEFT),
+ 'clock_seq_low' => substr($hash, 18, 2),
+ 'node' => substr($hash, 20, 12),
+ );
+
+ return $this->uuid($fields);
+ }
+}
diff --git a/vendor/ramsey/uuid/src/UuidFactoryInterface.php b/vendor/ramsey/uuid/src/UuidFactoryInterface.php
new file mode 100644
index 0000000000..6895ff2cf4
--- /dev/null
+++ b/vendor/ramsey/uuid/src/UuidFactoryInterface.php
@@ -0,0 +1,89 @@
+<?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;
+
+/**
+ * UuidFactoryInterface defines common functionality all `UuidFactory` instances
+ * must implement
+ */
+interface UuidFactoryInterface
+{
+ /**
+ * Generate a version 1 UUID from a host ID, sequence number, and the current time.
+ *
+ * @param int|string $node A 48-bit number representing the hardware address
+ * This number may be represented as an integer or a hexadecimal string.
+ * @param int $clockSeq A 14-bit number used to help avoid duplicates that
+ * could arise when the clock is set backwards in time or if the node ID
+ * changes.
+ * @return UuidInterface
+ */
+ public function uuid1($node = null, $clockSeq = null);
+
+ /**
+ * Generate a version 3 UUID based on the MD5 hash of a namespace identifier
+ * (which is a UUID) and a name (which is a string).
+ *
+ * @param string $ns The UUID namespace in which to create the named UUID
+ * @param string $name The name to create a UUID for
+ * @return UuidInterface
+ */
+ public function uuid3($ns, $name);
+
+ /**
+ * Generate a version 4 (random) UUID.
+ *
+ * @return UuidInterface
+ */
+ public function uuid4();
+
+ /**
+ * Generate a version 5 UUID based on the SHA-1 hash of a namespace
+ * identifier (which is a UUID) and a name (which is a string).
+ *
+ * @param string $ns The UUID namespace in which to create the named UUID
+ * @param string $name The name to create a UUID for
+ * @return UuidInterface
+ */
+ public function uuid5($ns, $name);
+
+ /**
+ * Creates a UUID from a byte string.
+ *
+ * @param string $bytes A 16-byte string representation of a UUID
+ * @return UuidInterface
+ */
+ public function fromBytes($bytes);
+
+ /**
+ * Creates a UUID from the string standard representation
+ *
+ * @param string $uuid A string representation of a UUID
+ * @return UuidInterface
+ */
+ public function fromString($uuid);
+
+ /**
+ * Creates a `Uuid` from an integer representation
+ *
+ * The integer representation may be a real integer, a string integer, or
+ * an integer representation supported by a configured number converter.
+ *
+ * @param mixed $integer The integer to use when creating a `Uuid` from an
+ * integer; may be of any type understood by the configured number converter
+ * @return UuidInterface
+ */
+ public function fromInteger($integer);
+}
diff --git a/vendor/ramsey/uuid/src/UuidInterface.php b/vendor/ramsey/uuid/src/UuidInterface.php
new file mode 100644
index 0000000000..792c32aad8
--- /dev/null
+++ b/vendor/ramsey/uuid/src/UuidInterface.php
@@ -0,0 +1,267 @@
+<?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;
+
+use Ramsey\Uuid\Converter\NumberConverterInterface;
+use Ramsey\Uuid\Exception\UnsupportedOperationException;
+
+/**
+ * UuidInterface defines common functionality for all universally unique
+ * identifiers (UUIDs)
+ */
+interface UuidInterface extends \JsonSerializable, \Serializable
+{
+ /**
+ * Compares this UUID to the specified UUID.
+ *
+ * The first of two UUIDs is greater than the second if the most
+ * significant field in which the UUIDs differ is greater for the first
+ * UUID.
+ *
+ * * Q. What's the value of being able to sort UUIDs?
+ * * A. Use them as keys in a B-Tree or similar mapping.
+ *
+ * @param UuidInterface $other UUID to which this UUID is compared
+ * @return int -1, 0 or 1 as this UUID is less than, equal to, or greater than `$uuid`
+ */
+ public function compareTo(UuidInterface $other);
+
+ /**
+ * Compares this object to the specified object.
+ *
+ * The result is true if and only if the argument is not null, is a UUID
+ * object, has the same variant, and contains the same value, bit for bit,
+ * as this UUID.
+ *
+ * @param object $other
+ * @return bool True if `$other` is equal to this UUID
+ */
+ public function equals($other);
+
+ /**
+ * Returns the UUID as a 16-byte string (containing the six integer fields
+ * in big-endian byte order).
+ *
+ * @return string
+ */
+ public function getBytes();
+
+ /**
+ * Returns the number converter to use for converting hex values to/from integers.
+ *
+ * @return NumberConverterInterface
+ */
+ public function getNumberConverter();
+
+ /**
+ * Returns the hexadecimal value of the UUID.
+ *
+ * @return string
+ */
+ public function getHex();
+
+ /**
+ * Returns an array of the fields of this UUID, with keys named according
+ * to the RFC 4122 names for the fields.
+ *
+ * * **time_low**: The low field of the timestamp, an unsigned 32-bit integer
+ * * **time_mid**: The middle field of the timestamp, an unsigned 16-bit integer
+ * * **time_hi_and_version**: The high field of the timestamp multiplexed with
+ * the version number, an unsigned 16-bit integer
+ * * **clock_seq_hi_and_reserved**: The high field of the clock sequence
+ * multiplexed with the variant, an unsigned 8-bit integer
+ * * **clock_seq_low**: The low field of the clock sequence, an unsigned
+ * 8-bit integer
+ * * **node**: The spatially unique node identifier, an unsigned 48-bit
+ * integer
+ *
+ * @return array The UUID fields represented as hexadecimal values
+ */
+ public function getFieldsHex();
+
+ /**
+ * Returns the high field of the clock sequence multiplexed with the variant
+ * (bits 65-72 of the UUID).
+ *
+ * @return string Hexadecimal value of clock_seq_hi_and_reserved
+ */
+ public function getClockSeqHiAndReservedHex();
+
+ /**
+ * Returns the low field of the clock sequence (bits 73-80 of the UUID).
+ *
+ * @return string Hexadecimal value of clock_seq_low
+ */
+ public function getClockSeqLowHex();
+
+ /**
+ * Returns the clock sequence value associated with this UUID.
+ *
+ * @return string Hexadecimal value of clock sequence
+ */
+ public function getClockSequenceHex();
+
+ /**
+ * Returns a PHP `DateTime` object representing the timestamp associated
+ * with this UUID.
+ *
+ * The timestamp value is only meaningful in a time-based UUID, which
+ * has version type 1. If this UUID is not a time-based UUID then
+ * this method throws `UnsupportedOperationException`.
+ *
+ * @return \DateTime A PHP DateTime representation of the date
+ * @throws UnsupportedOperationException If this UUID is not a version 1 UUID
+ */
+ public function getDateTime();
+
+ /**
+ * Returns the integer value of the UUID, converted to an appropriate number
+ * representation.
+ *
+ * @return mixed Converted representation of the unsigned 128-bit integer value
+ */
+ public function getInteger();
+
+ /**
+ * Returns the least significant 64 bits of this UUID's 128 bit value.
+ *
+ * @return string Hexadecimal value of least significant bits
+ */
+ public function getLeastSignificantBitsHex();
+
+ /**
+ * Returns the most significant 64 bits of this UUID's 128 bit value.
+ *
+ * @return string Hexadecimal value of most significant bits
+ */
+ public function getMostSignificantBitsHex();
+
+ /**
+ * Returns the node value associated with this UUID
+ *
+ * For UUID version 1, the node field consists of an IEEE 802 MAC
+ * address, usually the host address. For systems with multiple IEEE
+ * 802 addresses, any available one can be used. The lowest addressed
+ * octet (octet number 10) contains the global/local bit and the
+ * unicast/multicast bit, and is the first octet of the address
+ * transmitted on an 802.3 LAN.
+ *
+ * For systems with no IEEE address, a randomly or pseudo-randomly
+ * generated value may be used; see RFC 4122, Section 4.5. The
+ * multicast bit must be set in such addresses, in order that they
+ * will never conflict with addresses obtained from network cards.
+ *
+ * For UUID version 3 or 5, the node field is a 48-bit value constructed
+ * from a name as described in RFC 4122, Section 4.3.
+ *
+ * For UUID version 4, the node field is a randomly or pseudo-randomly
+ * generated 48-bit value as described in RFC 4122, Section 4.4.
+ *
+ * @return string Hexadecimal value of node
+ * @link http://tools.ietf.org/html/rfc4122#section-4.1.6
+ */
+ public function getNodeHex();
+
+ /**
+ * Returns the high field of the timestamp multiplexed with the version
+ * number (bits 49-64 of the UUID).
+ *
+ * @return string Hexadecimal value of time_hi_and_version
+ */
+ public function getTimeHiAndVersionHex();
+
+ /**
+ * Returns the low field of the timestamp (the first 32 bits of the UUID).
+ *
+ * @return string Hexadecimal value of time_low
+ */
+ public function getTimeLowHex();
+
+ /**
+ * Returns the middle field of the timestamp (bits 33-48 of the UUID).
+ *
+ * @return string Hexadecimal value of time_mid
+ */
+ public function getTimeMidHex();
+
+ /**
+ * Returns the timestamp value associated with this UUID.
+ *
+ * The 60 bit timestamp value is constructed from the time_low,
+ * time_mid, and time_hi fields of this UUID. The resulting
+ * timestamp is measured in 100-nanosecond units since midnight,
+ * October 15, 1582 UTC.
+ *
+ * The timestamp value is only meaningful in a time-based UUID, which
+ * has version type 1. If this UUID is not a time-based UUID then
+ * this method throws UnsupportedOperationException.
+ *
+ * @return string Hexadecimal value of the timestamp
+ * @throws UnsupportedOperationException If this UUID is not a version 1 UUID
+ * @link http://tools.ietf.org/html/rfc4122#section-4.1.4
+ */
+ public function getTimestampHex();
+
+ /**
+ * Returns the string representation of the UUID as a URN.
+ *
+ * @return string
+ * @link http://en.wikipedia.org/wiki/Uniform_Resource_Name
+ */
+ public function getUrn();
+
+ /**
+ * Returns the variant number associated with this UUID.
+ *
+ * The variant number describes the layout of the UUID. The variant
+ * number has the following meaning:
+ *
+ * * 0 - Reserved for NCS backward compatibility
+ * * 2 - The RFC 4122 variant (used by this class)
+ * * 6 - Reserved, Microsoft Corporation backward compatibility
+ * * 7 - Reserved for future definition
+ *
+ * @return int
+ * @link http://tools.ietf.org/html/rfc4122#section-4.1.1
+ */
+ public function getVariant();
+
+ /**
+ * Returns the version number associated with this UUID.
+ *
+ * The version number describes how this UUID was generated and has the
+ * following meaning:
+ *
+ * * 1 - Time-based UUID
+ * * 2 - DCE security UUID
+ * * 3 - Name-based UUID hashed with MD5
+ * * 4 - Randomly generated UUID
+ * * 5 - Name-based UUID hashed with SHA-1
+ *
+ * Returns null if this UUID is not an RFC 4122 variant, since version
+ * is only meaningful for this variant.
+ *
+ * @return int|null
+ * @link http://tools.ietf.org/html/rfc4122#section-4.1.3
+ */
+ public function getVersion();
+
+ /**
+ * Converts this UUID into a string representation.
+ *
+ * @return string
+ */
+ public function toString();
+}