初始化代码
This commit is contained in:
643
vendor/ramsey/uuid/CHANGELOG.md
vendored
Normal file
643
vendor/ramsey/uuid/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,643 @@
|
||||
# ramsey/uuid Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
### Fixed
|
||||
|
||||
### Security
|
||||
|
||||
|
||||
## [3.9.2] - 2019-12-17
|
||||
|
||||
### Fixed
|
||||
|
||||
* Check whether files returned by `/sys/class/net/*/address` are readable
|
||||
before attempting to read them. This avoids a PHP warning that was being
|
||||
emitted on hosts that do not grant permission to read these files.
|
||||
|
||||
|
||||
## [3.9.1] - 2019-12-01
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fix `RandomNodeProvider` behavior on 32-bit systems. The `RandomNodeProvider`
|
||||
was converting a 6-byte string to a decimal number, which is a 48-bit,
|
||||
unsigned integer. This caused problems on 32-bit systems and has now been
|
||||
resolved.
|
||||
|
||||
|
||||
## [3.9.0] - 2019-11-30
|
||||
|
||||
### Added
|
||||
|
||||
* Add function API as convenience. The functions are available in the
|
||||
`Ramsey\Uuid` namespace.
|
||||
* `v1(int|string|null $node = null, int|null $clockSeq = null): string`
|
||||
* `v3(string|UuidInterface $ns, string $name): string`
|
||||
* `v4(): string`
|
||||
* `v5(string|UuidInterface $ns, string $name): string`
|
||||
|
||||
### Changed
|
||||
|
||||
* Use paragonie/random-lib instead of ircmaxell/random-lib. This is a
|
||||
non-breaking change.
|
||||
* Use a high-strength generator by default, when using `RandomLibAdapter`. This
|
||||
is a non-breaking change.
|
||||
|
||||
### Deprecated
|
||||
|
||||
These will be removed in ramsey/uuid version 4.0.0:
|
||||
|
||||
* `MtRandGenerator`, `OpenSslGenerator`, and `SodiumRandomGenerator` are
|
||||
deprecated in favor of using the default `RandomBytesGenerator`.
|
||||
|
||||
### Fixed
|
||||
|
||||
* Set `ext-json` as a required dependency in `composer.json`.
|
||||
* Use `PHP_OS` instead of `php_uname()` when determining the system OS, for
|
||||
cases when `php_uname()` is disabled for security reasons.
|
||||
|
||||
|
||||
## [3.8.0] - 2018-07-19
|
||||
|
||||
### Added
|
||||
|
||||
* Support discovery of MAC addresses on FreeBSD systems
|
||||
* Use a polyfill to provide PHP ctype functions when running on systems where the
|
||||
ctype functions are not part of the PHP build
|
||||
* Disallow a trailing newline character when validating UUIDs
|
||||
* Annotate thrown exceptions for improved IDE hinting
|
||||
|
||||
|
||||
## [3.7.3] - 2018-01-19
|
||||
|
||||
### Fixed
|
||||
|
||||
* Gracefully handle cases where `glob()` returns false when searching
|
||||
`/sys/class/net/*/address` files on Linux
|
||||
* Fix off-by-one error in `DefaultTimeGenerator`
|
||||
|
||||
### Security
|
||||
|
||||
* Switch to `random_int()` from `mt_rand()` for better random numbers
|
||||
|
||||
|
||||
## [3.7.2] - 2018-01-13
|
||||
|
||||
### Fixed
|
||||
|
||||
* Check sysfs on Linux to determine the node identifier; this provides a
|
||||
reliable way to identify the node on Docker images, etc.
|
||||
|
||||
|
||||
## [3.7.1] - 2017-09-22
|
||||
|
||||
### Fixed
|
||||
|
||||
* Set the multicast bit for random nodes, according to RFC 4122, §4.5
|
||||
|
||||
### Security
|
||||
|
||||
* Use `random_bytes()` when generating random nodes
|
||||
|
||||
|
||||
## [3.7.0] - 2017-08-04
|
||||
|
||||
### Added
|
||||
|
||||
* Add the following UUID version constants:
|
||||
* `Uuid::UUID_TYPE_TIME`
|
||||
* `Uuid::UUID_TYPE_IDENTIFIER`
|
||||
* `Uuid::UUID_TYPE_HASH_MD5`
|
||||
* `Uuid::UUID_TYPE_RANDOM`
|
||||
* `Uuid::UUID_TYPE_HASH_SHA1`
|
||||
|
||||
|
||||
## [3.6.1] - 2017-03-26
|
||||
|
||||
### Fixed
|
||||
|
||||
* Optimize UUID string decoding by using `str_pad()` instead of `sprintf()`
|
||||
|
||||
|
||||
## [3.6.0] - 2017-03-18
|
||||
|
||||
### Added
|
||||
|
||||
* Add `InvalidUuidStringException`, which is thrown when attempting to decode an
|
||||
invalid string UUID; this does not introduce any BC issues, since the new
|
||||
exception inherits from the previously used `InvalidArgumentException`
|
||||
|
||||
### Fixed
|
||||
|
||||
* Improve memory usage when generating large quantities of UUIDs (use `str_pad()`
|
||||
and `dechex()` instead of `sprintf()`)
|
||||
|
||||
|
||||
## [3.5.2] - 2016-11-22
|
||||
|
||||
### Fixed
|
||||
|
||||
* Improve test coverage
|
||||
|
||||
|
||||
## [3.5.1] - 2016-10-02
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fix issue where the same UUIDs were not being treated as equal when using
|
||||
mixed cases
|
||||
|
||||
|
||||
## [3.5.0] - 2016-08-02
|
||||
|
||||
### Added
|
||||
|
||||
* Add `OrderedTimeCodec` to store UUID in an optimized way for InnoDB
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fix invalid node generation in `RandomNodeProvider`
|
||||
* Avoid multiple unnecessary system calls by caching failed attempt to retrieve
|
||||
system node
|
||||
|
||||
|
||||
## [3.4.1] - 2016-04-23
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fix test that violated a PHP CodeSniffer rule, breaking the build
|
||||
|
||||
|
||||
## [3.4.0] - 2016-04-23
|
||||
|
||||
### Added
|
||||
|
||||
* Add `TimestampFirstCombCodec` and `TimestampLastCombCodec` codecs to provide
|
||||
the ability to generate [COMB sequential UUIDs] with the timestamp encoded as
|
||||
either the first 48 bits or the last 48 bits
|
||||
* Improve logic of `CombGenerator` for COMB sequential UUIDs
|
||||
|
||||
|
||||
## [3.3.0] - 2016-03-22
|
||||
|
||||
### Security
|
||||
|
||||
* Drop the use of OpenSSL as a fallback and use [paragonie/random_compat] to
|
||||
support `RandomBytesGenerator` in versions of PHP earlier than 7.0;
|
||||
this addresses and fixes the [collision issue]
|
||||
|
||||
|
||||
## [3.2.0] - 2016-02-17
|
||||
|
||||
### Added
|
||||
|
||||
* Add `SodiumRandomGenerator` to allow use of the [PECL libsodium extension] as
|
||||
a random bytes generator when creating UUIDs
|
||||
|
||||
|
||||
## [3.1.0] - 2015-12-17
|
||||
|
||||
### Added
|
||||
|
||||
* Implement the PHP `Serializable` interface to provide the ability to
|
||||
serialize/unserialize UUID objects
|
||||
|
||||
|
||||
## [3.0.1] - 2015-10-21
|
||||
|
||||
### Added
|
||||
|
||||
* Adopt the [Contributor Code of Conduct] for this project
|
||||
|
||||
|
||||
## [3.0.0] - 2015-09-28
|
||||
|
||||
The 3.0.0 release represents a significant step for the ramsey/uuid library.
|
||||
While the simple and familiar API used in previous versions remains intact, this
|
||||
release provides greater flexibility to integrators, including the ability to
|
||||
inject your own number generators, UUID codecs, node and time providers, and
|
||||
more.
|
||||
|
||||
*Please note: The changelog for 3.0.0 includes all notes from the alpha and beta
|
||||
versions leading up to this release.*
|
||||
|
||||
### Added
|
||||
|
||||
* Add a number of generators that may be used to override the library defaults
|
||||
for generating random bytes (version 4) or time-based (version 1) UUIDs
|
||||
* `CombGenerator` to allow generation of sequential UUIDs
|
||||
* `OpenSslGenerator` to generate random bytes on systems where
|
||||
`openssql_random_pseudo_bytes()` is present
|
||||
* `MtRandGenerator` to provide a fallback in the event other random generators
|
||||
are not present
|
||||
* `RandomLibAdapter` to allow use of [ircmaxell/random-lib]
|
||||
* `RandomBytesGenerator` for use with PHP 7; ramsey/uuid will default to use
|
||||
this generator when running on PHP 7
|
||||
* Refactor time-based (version 1) UUIDs into a `TimeGeneratorInterface` to
|
||||
allow for other sources to generate version 1 UUIDs in this library
|
||||
* `PeclUuidTimeGenerator` and `PeclUuidRandomGenerator` for creating version
|
||||
1 or version 4 UUIDs using the pecl-uuid extension
|
||||
* Add a `setTimeGenerator` method on `UuidFactory` to override the default time
|
||||
generator
|
||||
* Add option to enable `PeclUuidTimeGenerator` via `FeatureSet`
|
||||
* Support GUID generation by configuring a `FeatureSet` to use GUIDs
|
||||
* Allow UUIDs to be serialized as JSON through `JsonSerializable`
|
||||
|
||||
### Changed
|
||||
|
||||
* Change root namespace from "Rhumsaa" to "Ramsey;" in most cases, simply
|
||||
making this change in your applications is the only upgrade path you will
|
||||
need—everything else should work as expected
|
||||
* No longer consider `Uuid` class as `final`; everything is now based around
|
||||
interfaces and factories, allowing you to use this package as a base to
|
||||
implement other kinds of UUIDs with different dependencies
|
||||
* Return an object of type `DegradedUuid` on 32-bit systems to indicate that
|
||||
certain features are not available
|
||||
* Default `RandomLibAdapter` to a medium-strength generator with
|
||||
[ircmaxell/random-lib]; this is configurable, so other generator strengths may
|
||||
be used
|
||||
|
||||
### Removed
|
||||
|
||||
* Remove `PeclUuidFactory` in favor of using pecl-uuid with generators
|
||||
* Remove `timeConverter` and `timeProvider` properties, setters, and getters in
|
||||
both `FeatureSet` and `UuidFactory` as those are now exclusively used by the
|
||||
default `TimeGenerator`
|
||||
* Move UUID [Doctrine field type] to [ramsey/uuid-doctrine]
|
||||
* Move `uuid` console application to [ramsey/uuid-console]
|
||||
* Remove `Uuid::VERSION` package version constant
|
||||
|
||||
### Fixed
|
||||
|
||||
* Improve GUID support to ensure that:
|
||||
* On little endian (LE) architectures, the byte order of the first three
|
||||
fields is LE
|
||||
* On big endian (BE) architectures, it is the same as a GUID
|
||||
* String representation is always the same
|
||||
* Fix exception message for `DegradedNumberConverter::fromHex()`
|
||||
|
||||
|
||||
## [3.0.0-beta1] - 2015-08-31
|
||||
|
||||
### Fixed
|
||||
|
||||
* Improve GUID support to ensure that:
|
||||
* On little endian (LE) architectures, the byte order of the first three
|
||||
fields is LE
|
||||
* On big endian (BE) architectures, it is the same as a GUID
|
||||
* String representation is always the same
|
||||
* Fix exception message for `DegradedNumberConverter::fromHex()`
|
||||
|
||||
|
||||
## [3.0.0-alpha3] - 2015-07-28
|
||||
|
||||
### Added
|
||||
|
||||
* Enable use of custom `TimeGenerator` implementations
|
||||
* Add a `setTimeGenerator` method on `UuidFactory` to override the default time
|
||||
generator
|
||||
* Add option to enable `PeclUuidTimeGenerator` via `FeatureSet`
|
||||
|
||||
### Removed
|
||||
|
||||
* Remove `timeConverter` and `timeProvider` properties, setters, and getters in
|
||||
both `FeatureSet` and `UuidFactory` as those are now exclusively used by the
|
||||
default `TimeGenerator`
|
||||
|
||||
|
||||
## [3.0.0-alpha2] - 2015-07-28
|
||||
|
||||
### Added
|
||||
|
||||
* Refactor time-based (version 1) UUIDs into a `TimeGeneratorInterface` to allow
|
||||
for other sources to generate version 1 UUIDs in this library
|
||||
* Add `PeclUuidTimeGenerator` and `PeclUuidRandomGenerator` for creating version
|
||||
1 or version 4 UUIDs using the pecl-uuid extension
|
||||
* Add `RandomBytesGenerator` for use with PHP 7. ramsey/uuid will default to use
|
||||
this generator when running on PHP 7
|
||||
|
||||
### Changed
|
||||
|
||||
* Default `RandomLibAdapter` to a medium-strength generator with
|
||||
[ircmaxell/random-lib]; this is configurable, so other generator strengths may
|
||||
be used
|
||||
|
||||
### Removed
|
||||
|
||||
* Remove `PeclUuidFactory` in favor of using pecl-uuid with generators
|
||||
|
||||
|
||||
## [3.0.0-alpha1] - 2015-07-16
|
||||
|
||||
### Added
|
||||
|
||||
* Allow dependency injection through `UuidFactory` and/or extending `FeatureSet`
|
||||
to override any package defaults
|
||||
* Add a number of generators that may be used to override the library defaults:
|
||||
* `CombGenerator` to allow generation of sequential UUIDs
|
||||
* `OpenSslGenerator` to generate random bytes on systems where
|
||||
`openssql_random_pseudo_bytes()` is present
|
||||
* `MtRandGenerator` to provide a fallback in the event other random generators
|
||||
are not present
|
||||
* `RandomLibAdapter` to allow use of [ircmaxell/random-lib]
|
||||
* Support GUID generation by configuring a `FeatureSet` to use GUIDs
|
||||
* Allow UUIDs to be serialized as JSON through `JsonSerializable`
|
||||
|
||||
### Changed
|
||||
|
||||
* Change root namespace from "Rhumsaa" to "Ramsey;" in most cases, simply
|
||||
making this change in your applications is the only upgrade path you will
|
||||
need—everything else should work as expected
|
||||
* No longer consider `Uuid` class as `final`; everything is now based around
|
||||
interfaces and factories, allowing you to use this package as a base to
|
||||
implement other kinds of UUIDs with different dependencies
|
||||
* Return an object of type `DegradedUuid` on 32-bit systems to indicate that
|
||||
certain features are not available
|
||||
|
||||
### Removed
|
||||
|
||||
* Move UUID [Doctrine field type] to [ramsey/uuid-doctrine]
|
||||
* Move `uuid` console application to [ramsey/uuid-console]
|
||||
* Remove `Uuid::VERSION` package version constant
|
||||
|
||||
|
||||
## [2.9.0] - 2016-03-22
|
||||
|
||||
### Security
|
||||
|
||||
* Drop the use of OpenSSL as a fallback and use [paragonie/random_compat] to
|
||||
support `RandomBytesGenerator` in versions of PHP earlier than 7.0;
|
||||
this addresses and fixes the [collision issue]
|
||||
|
||||
|
||||
## [2.8.4] - 2015-12-17
|
||||
|
||||
### Added
|
||||
|
||||
* Add support for symfony/console v3 in the `uuid` CLI application
|
||||
|
||||
|
||||
## [2.8.3] - 2015-08-31
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fix exception message in `Uuid::calculateUuidTime()`
|
||||
|
||||
|
||||
## [2.8.2] - 2015-07-23
|
||||
|
||||
### Fixed
|
||||
|
||||
* Ensure the release tag makes it into the rhumsaa/uuid package
|
||||
|
||||
|
||||
## [2.8.1] - 2015-06-16
|
||||
|
||||
### Fixed
|
||||
|
||||
* Use `passthru()` and output buffering in `getIfconfig()`
|
||||
* Cache the system node in a static variable so that we process it only once per
|
||||
runtime
|
||||
|
||||
|
||||
## [2.8.0] - 2014-11-09
|
||||
|
||||
### Added
|
||||
|
||||
* Add static `fromInteger()` method to create UUIDs from string integer or
|
||||
`Moontoast\Math\BigNumber`
|
||||
|
||||
### Fixed
|
||||
|
||||
* Improve Doctrine conversion to Uuid or string for the ramsey/uuid [Doctrine
|
||||
field type]
|
||||
|
||||
|
||||
## [2.7.4] - 2014-10-29
|
||||
|
||||
### Fixed
|
||||
|
||||
* Change loop in `generateBytes()` from `foreach` to `for`
|
||||
|
||||
|
||||
## [2.7.3] - 2014-08-27
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fix upper range for `mt_rand` used in version 4 UUIDs
|
||||
|
||||
|
||||
## [2.7.2] - 2014-07-28
|
||||
|
||||
### Changed
|
||||
|
||||
* Upgrade to PSR-4 autoloading
|
||||
|
||||
|
||||
## [2.7.1] - 2014-02-19
|
||||
|
||||
### Fixed
|
||||
|
||||
* Move moontoast/math and symfony/console to require-dev
|
||||
* Support symfony/console 2.3 (LTS version)
|
||||
|
||||
|
||||
## [2.7.0] - 2014-01-31
|
||||
|
||||
### Added
|
||||
|
||||
* Add `Uuid::VALID_PATTERN` constant containing a UUID validation regex pattern
|
||||
|
||||
|
||||
## [2.6.1] - 2014-01-27
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fix bug where `uuid` console application could not find the Composer
|
||||
autoloader when installed in another project
|
||||
|
||||
|
||||
## [2.6.0] - 2014-01-17
|
||||
|
||||
### Added
|
||||
|
||||
* Introduce `uuid` console application for generating and decoding UUIDs from
|
||||
CLI (run `./bin/uuid` for details)
|
||||
* Add `Uuid::getInteger()` to retrieve a `Moontoast\Math\BigNumber`
|
||||
representation of the 128-bit integer representing the UUID
|
||||
* Add `Uuid::getHex()` to retrieve the hexadecimal representation of the UUID
|
||||
* Use `netstat` on Linux to capture the node for a version 1 UUID
|
||||
* Require moontoast/math as part of the regular package requirements
|
||||
|
||||
|
||||
## [2.5.0] - 2013-10-30
|
||||
|
||||
### Added
|
||||
|
||||
* Use `openssl_random_pseudo_bytes()`, if available, to generate random bytes
|
||||
|
||||
|
||||
## [2.4.0] - 2013-07-29
|
||||
|
||||
### Added
|
||||
|
||||
* Return `null` from `Uuid::getVersion()` if the UUID isn't an RFC 4122 variant
|
||||
* Support string UUIDs without dashes passed to `Uuid::fromString()`
|
||||
|
||||
|
||||
## [2.3.0] - 2013-07-16
|
||||
|
||||
### Added
|
||||
|
||||
* Support creation of UUIDs from bytes with `Uuid::fromBytes()`
|
||||
|
||||
|
||||
## [2.2.0] - 2013-07-04
|
||||
|
||||
### Added
|
||||
|
||||
* Add `Doctrine\UuidType::requiresSQLCommentHint()` method
|
||||
|
||||
|
||||
## [2.1.2] - 2013-07-03
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fix cases where the system node was coming back with uppercase hexadecimal
|
||||
digits; this ensures that case in the node is converted to lowercase
|
||||
|
||||
|
||||
## [2.1.1] - 2013-04-29
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fix bug in `Uuid::isValid()` where the NIL UUID was not reported as valid
|
||||
|
||||
|
||||
## [2.1.0] - 2013-04-15
|
||||
|
||||
### Added
|
||||
|
||||
* Allow checking the validity of a UUID through the `Uuid::isValid()` method
|
||||
|
||||
|
||||
## [2.0.0] - 2013-02-11
|
||||
|
||||
### Added
|
||||
|
||||
* Support UUID generation on 32-bit platforms
|
||||
|
||||
### Changed
|
||||
|
||||
* Mark `Uuid` class `final`
|
||||
* Require moontoast/math on 64-bit platforms for
|
||||
`Uuid::getLeastSignificantBits()` and `Uuid::getMostSignificantBits()`; the
|
||||
integers returned by these methods are *unsigned* 64-bit integers and
|
||||
unsupported even on 64-bit builds of PHP
|
||||
* Move `UnsupportedOperationException` to the `Exception` subnamespace
|
||||
|
||||
|
||||
## [1.1.2] - 2012-11-29
|
||||
|
||||
### Fixed
|
||||
|
||||
* Relax [Doctrine field type] conversion rules for UUIDs
|
||||
|
||||
|
||||
## [1.1.1] - 2012-08-27
|
||||
|
||||
### Fixed
|
||||
|
||||
* Remove `final` keyword from `Uuid` class
|
||||
|
||||
|
||||
## [1.1.0] - 2012-08-06
|
||||
|
||||
### Added
|
||||
|
||||
* Support ramsey/uuid UUIDs as a Doctrine Database Abstraction Layer (DBAL)
|
||||
field mapping type
|
||||
|
||||
|
||||
## [1.0.0] - 2012-07-19
|
||||
|
||||
### Added
|
||||
|
||||
* Support generation of version 1, 3, 4, and 5 UUIDs
|
||||
|
||||
|
||||
[comb sequential uuids]: http://www.informit.com/articles/article.aspx?p=25862&seqNum=7
|
||||
[paragonie/random_compat]: https://github.com/paragonie/random_compat
|
||||
[collision issue]: https://github.com/ramsey/uuid/issues/80
|
||||
[contributor code of conduct]: https://github.com/ramsey/uuid/blob/master/.github/CODE_OF_CONDUCT.md
|
||||
[pecl libsodium extension]: http://pecl.php.net/package/libsodium
|
||||
[ircmaxell/random-lib]: https://github.com/ircmaxell/RandomLib
|
||||
[doctrine field type]: http://doctrine-dbal.readthedocs.org/en/latest/reference/types.html
|
||||
[ramsey/uuid-doctrine]: https://github.com/ramsey/uuid-doctrine
|
||||
[ramsey/uuid-console]: https://github.com/ramsey/uuid-console
|
||||
|
||||
[unreleased]: https://github.com/ramsey/uuid/compare/3.9.2...HEAD
|
||||
[3.9.2]: https://github.com/ramsey/uuid/compare/3.9.1...3.9.2
|
||||
[3.9.1]: https://github.com/ramsey/uuid/compare/3.9.0...3.9.1
|
||||
[3.9.0]: https://github.com/ramsey/uuid/compare/3.8.0...3.9.0
|
||||
[3.8.0]: https://github.com/ramsey/uuid/compare/3.7.3...3.8.0
|
||||
[3.7.3]: https://github.com/ramsey/uuid/compare/3.7.2...3.7.3
|
||||
[3.7.2]: https://github.com/ramsey/uuid/compare/3.7.1...3.7.2
|
||||
[3.7.1]: https://github.com/ramsey/uuid/compare/3.7.0...3.7.1
|
||||
[3.7.0]: https://github.com/ramsey/uuid/compare/3.6.1...3.7.0
|
||||
[3.6.1]: https://github.com/ramsey/uuid/compare/3.6.0...3.6.1
|
||||
[3.6.0]: https://github.com/ramsey/uuid/compare/3.5.2...3.6.0
|
||||
[3.5.2]: https://github.com/ramsey/uuid/compare/3.5.1...3.5.2
|
||||
[3.5.1]: https://github.com/ramsey/uuid/compare/3.5.0...3.5.1
|
||||
[3.5.0]: https://github.com/ramsey/uuid/compare/3.4.1...3.5.0
|
||||
[3.4.1]: https://github.com/ramsey/uuid/compare/3.4.0...3.4.1
|
||||
[3.4.0]: https://github.com/ramsey/uuid/compare/3.3.0...3.4.0
|
||||
[3.3.0]: https://github.com/ramsey/uuid/compare/3.2.0...3.3.0
|
||||
[3.2.0]: https://github.com/ramsey/uuid/compare/3.1.0...3.2.0
|
||||
[3.1.0]: https://github.com/ramsey/uuid/compare/3.0.1...3.1.0
|
||||
[3.0.1]: https://github.com/ramsey/uuid/compare/3.0.0...3.0.1
|
||||
[3.0.0]: https://github.com/ramsey/uuid/compare/3.0.0-beta1...3.0.0
|
||||
[3.0.0-beta1]: https://github.com/ramsey/uuid/compare/3.0.0-alpha3...3.0.0-beta1
|
||||
[3.0.0-alpha3]: https://github.com/ramsey/uuid/compare/3.0.0-alpha2...3.0.0-alpha3
|
||||
[3.0.0-alpha2]: https://github.com/ramsey/uuid/compare/3.0.0-alpha1...3.0.0-alpha2
|
||||
[3.0.0-alpha1]: https://github.com/ramsey/uuid/compare/2.9.0...3.0.0-alpha1
|
||||
[2.9.0]: https://github.com/ramsey/uuid/compare/2.8.4...2.9.0
|
||||
[2.8.4]: https://github.com/ramsey/uuid/compare/2.8.3...2.8.4
|
||||
[2.8.3]: https://github.com/ramsey/uuid/compare/2.8.2...2.8.3
|
||||
[2.8.2]: https://github.com/ramsey/uuid/compare/2.8.1...2.8.2
|
||||
[2.8.1]: https://github.com/ramsey/uuid/compare/2.8.0...2.8.1
|
||||
[2.8.0]: https://github.com/ramsey/uuid/compare/2.7.4...2.8.0
|
||||
[2.7.4]: https://github.com/ramsey/uuid/compare/2.7.3...2.7.4
|
||||
[2.7.3]: https://github.com/ramsey/uuid/compare/2.7.2...2.7.3
|
||||
[2.7.2]: https://github.com/ramsey/uuid/compare/2.7.1...2.7.2
|
||||
[2.7.1]: https://github.com/ramsey/uuid/compare/2.7.0...2.7.1
|
||||
[2.7.0]: https://github.com/ramsey/uuid/compare/2.6.1...2.7.0
|
||||
[2.6.1]: https://github.com/ramsey/uuid/compare/2.6.0...2.6.1
|
||||
[2.6.0]: https://github.com/ramsey/uuid/compare/2.5.0...2.6.0
|
||||
[2.5.0]: https://github.com/ramsey/uuid/compare/2.4.0...2.5.0
|
||||
[2.4.0]: https://github.com/ramsey/uuid/compare/2.3.0...2.4.0
|
||||
[2.3.0]: https://github.com/ramsey/uuid/compare/2.2.0...2.3.0
|
||||
[2.2.0]: https://github.com/ramsey/uuid/compare/2.1.2...2.2.0
|
||||
[2.1.2]: https://github.com/ramsey/uuid/compare/2.1.1...2.1.2
|
||||
[2.1.1]: https://github.com/ramsey/uuid/compare/2.1.0...2.1.1
|
||||
[2.1.0]: https://github.com/ramsey/uuid/compare/2.0.0...2.1.0
|
||||
[2.0.0]: https://github.com/ramsey/uuid/compare/1.1.2...2.0.0
|
||||
[1.1.2]: https://github.com/ramsey/uuid/compare/1.1.1...1.1.2
|
||||
[1.1.1]: https://github.com/ramsey/uuid/compare/1.1.0...1.1.1
|
||||
[1.1.0]: https://github.com/ramsey/uuid/compare/1.0.0...1.1.0
|
||||
[1.0.0]: https://github.com/ramsey/uuid/commits/1.0.0
|
||||
21
vendor/ramsey/uuid/LICENSE
vendored
Normal file
21
vendor/ramsey/uuid/LICENSE
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2012-2019 Ben Ramsey <ben@benramsey.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
185
vendor/ramsey/uuid/README.md
vendored
Normal file
185
vendor/ramsey/uuid/README.md
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
# ramsey/uuid
|
||||
|
||||
*NOTICE: Formerly known as `rhumsaa/uuid`, The package and namespace names have
|
||||
changed to `ramsey/uuid` and `Ramsey\Uuid`, respectively.*
|
||||
|
||||
[![Source Code][badge-source]][source]
|
||||
[![Latest Version][badge-release]][release]
|
||||
[![Software License][badge-license]][license]
|
||||
[![PHP Version][badge-php]][php]
|
||||
[![Build Status][badge-build]][build]
|
||||
[![Coverage Status][badge-coverage]][coverage]
|
||||
[![Total Downloads][badge-downloads]][downloads]
|
||||
|
||||
ramsey/uuid is a PHP 5.4+ library for generating and working with
|
||||
[RFC 4122][rfc4122] version 1, 3, 4, and 5 universally unique identifiers
|
||||
(UUID).
|
||||
|
||||
This project adheres to a [Contributor Code of Conduct][conduct]. By
|
||||
participating in this project and its community, you are expected to uphold this
|
||||
code.
|
||||
|
||||
From [Wikipedia](http://en.wikipedia.org/wiki/Universally_unique_identifier):
|
||||
|
||||
> The intent of UUIDs is to enable distributed systems to uniquely identify
|
||||
> information without significant central coordination. In this context the word
|
||||
> unique should be taken to mean "practically unique" rather than "guaranteed
|
||||
> unique". Since the identifiers have a finite size, it is possible for two
|
||||
> differing items to share the same identifier. The identifier size and
|
||||
> generation process need to be selected so as to make this sufficiently
|
||||
> improbable in practice. Anyone can create a UUID and use it to identify
|
||||
> something with reasonable confidence that the same identifier will never be
|
||||
> unintentionally created by anyone to identify something else. Information
|
||||
> labeled with UUIDs can therefore be later combined into a single database
|
||||
> without needing to resolve identifier (ID) conflicts.
|
||||
|
||||
Much inspiration for this library came from the [Java][javauuid] and
|
||||
[Python][pyuuid] UUID libraries.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
The preferred method of installation is via [Composer][]. Run the following
|
||||
command to install the package and add it as a requirement to your project's
|
||||
`composer.json`:
|
||||
|
||||
```bash
|
||||
composer require ramsey/uuid
|
||||
```
|
||||
|
||||
|
||||
## Upgrading from 2.x to 3.x
|
||||
|
||||
While we have made significant internal changes to the library, we have made
|
||||
every effort to ensure a seamless upgrade path from the 2.x series of this
|
||||
library to 3.x.
|
||||
|
||||
One major breaking change is the transition from the `Rhumsaa` root namespace to
|
||||
`Ramsey`. In most cases, all you will need is to change the namespace to
|
||||
`Ramsey` in your code, and everything will "just work."
|
||||
|
||||
Here are full details on the breaking changes to the public API of this library:
|
||||
|
||||
1. All namespace references of `Rhumsaa` have changed to `Ramsey`. Simply change
|
||||
the namespace to `Ramsey` in your code and everything should work.
|
||||
2. The console application has moved to
|
||||
[ramsey/uuid-console](https://packagist.org/packages/ramsey/uuid-console).
|
||||
If using the console functionality, use Composer to require
|
||||
`ramsey/uuid-console`.
|
||||
3. The Doctrine field type mapping has moved to
|
||||
[ramsey/uuid-doctrine](https://packagist.org/packages/ramsey/uuid-doctrine).
|
||||
If using the Doctrine functionality, use Composer to require
|
||||
`ramsey/uuid-doctrine`.
|
||||
|
||||
|
||||
## What to do if you see a "rhumsaa/uuid is abandoned" message
|
||||
|
||||
When installing your project's dependencies using Composer, you might see the
|
||||
following message:
|
||||
|
||||
```
|
||||
Package rhumsaa/uuid is abandoned, you should avoid using it. Use
|
||||
ramsey/uuid instead.
|
||||
```
|
||||
|
||||
Don't panic. Simply execute the following commands with Composer:
|
||||
|
||||
``` bash
|
||||
composer remove rhumsaa/uuid
|
||||
composer require ramsey/uuid=^2.9
|
||||
```
|
||||
|
||||
After doing so, you will have the latest ramsey/uuid package in the 2.x series,
|
||||
and there will be no need to modify any code; the namespace in the 2.x series is
|
||||
still `Rhumsaa`.
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
Some methods in this library have requirements due to integer size restrictions
|
||||
on 32-bit and 64-bit builds of PHP. A 64-bit build of PHP and the
|
||||
[Moontoast\Math][] library are recommended. However, this library is designed to
|
||||
work on 32-bit builds of PHP without Moontoast\Math, with some degraded
|
||||
functionality. Please check the API documentation for more information.
|
||||
|
||||
If a particular requirement is not present, then an
|
||||
`UnsatisfiedDependencyException` is thrown, allowing one to catch a bad call in
|
||||
an environment where the call is not supported and gracefully degrade.
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
See the [cookbook on the wiki][wiki-cookbook] for more examples and approaches
|
||||
to specific use-cases.
|
||||
|
||||
```php
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
|
||||
|
||||
try {
|
||||
|
||||
// Generate a version 1 (time-based) UUID object
|
||||
$uuid1 = Uuid::uuid1();
|
||||
echo $uuid1->toString() . "\n"; // i.e. e4eaaaf2-d142-11e1-b3e4-080027620cdd
|
||||
|
||||
// Generate a version 3 (name-based and hashed with MD5) UUID object
|
||||
$uuid3 = Uuid::uuid3(Uuid::NAMESPACE_DNS, 'php.net');
|
||||
echo $uuid3->toString() . "\n"; // i.e. 11a38b9a-b3da-360f-9353-a5a725514269
|
||||
|
||||
// Generate a version 4 (random) UUID object
|
||||
$uuid4 = Uuid::uuid4();
|
||||
echo $uuid4->toString() . "\n"; // i.e. 25769c6c-d34d-4bfe-ba98-e0ee856f3e7a
|
||||
|
||||
// Generate a version 5 (name-based and hashed with SHA1) UUID object
|
||||
$uuid5 = Uuid::uuid5(Uuid::NAMESPACE_DNS, 'php.net');
|
||||
echo $uuid5->toString() . "\n"; // i.e. c4a760a8-dbcf-5254-a0d9-6a4474bd1b62
|
||||
|
||||
} catch (UnsatisfiedDependencyException $e) {
|
||||
|
||||
// Some dependency was not met. Either the method cannot be called on a
|
||||
// 32-bit system, or it can, but it relies on Moontoast\Math to be present.
|
||||
echo 'Caught exception: ' . $e->getMessage() . "\n";
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! Please read [CONTRIBUTING.md][] for details.
|
||||
|
||||
|
||||
## Copyright and License
|
||||
|
||||
The ramsey/uuid library is copyright © [Ben Ramsey](https://benramsey.com/) and
|
||||
licensed for use under the MIT License (MIT). Please see [LICENSE][] for more
|
||||
information.
|
||||
|
||||
|
||||
[rfc4122]: http://tools.ietf.org/html/rfc4122
|
||||
[conduct]: https://github.com/ramsey/uuid/blob/master/.github/CODE_OF_CONDUCT.md
|
||||
[javauuid]: http://docs.oracle.com/javase/6/docs/api/java/util/UUID.html
|
||||
[pyuuid]: http://docs.python.org/3/library/uuid.html
|
||||
[composer]: http://getcomposer.org/
|
||||
[moontoast\math]: https://packagist.org/packages/moontoast/math
|
||||
[wiki-cookbook]: https://github.com/ramsey/uuid/wiki/Ramsey%5CUuid-Cookbook
|
||||
[contributing.md]: https://github.com/ramsey/uuid/blob/master/.github/CONTRIBUTING.md
|
||||
|
||||
[badge-source]: https://img.shields.io/badge/source-ramsey/uuid-blue.svg?style=flat-square
|
||||
[badge-release]: https://img.shields.io/packagist/v/ramsey/uuid.svg?style=flat-square&label=release
|
||||
[badge-license]: https://img.shields.io/packagist/l/ramsey/uuid.svg?style=flat-square
|
||||
[badge-php]: https://img.shields.io/packagist/php-v/ramsey/uuid.svg?style=flat-square
|
||||
[badge-build]: https://img.shields.io/travis/ramsey/uuid/master.svg?style=flat-square
|
||||
[badge-coverage]: https://img.shields.io/coveralls/github/ramsey/uuid/master.svg?style=flat-square
|
||||
[badge-downloads]: https://img.shields.io/packagist/dt/ramsey/uuid.svg?style=flat-square&colorB=mediumvioletred
|
||||
|
||||
[source]: https://github.com/ramsey/uuid
|
||||
[release]: https://packagist.org/packages/ramsey/uuid
|
||||
[license]: https://github.com/ramsey/uuid/blob/master/LICENSE
|
||||
[php]: https://php.net
|
||||
[build]: https://travis-ci.org/ramsey/uuid
|
||||
[coverage]: https://coveralls.io/github/ramsey/uuid?branch=master
|
||||
[downloads]: https://packagist.org/packages/ramsey/uuid
|
||||
92
vendor/ramsey/uuid/composer.json
vendored
Normal file
92
vendor/ramsey/uuid/composer.json
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"name": "ramsey/uuid",
|
||||
"type": "library",
|
||||
"description": "Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).",
|
||||
"keywords": ["uuid", "identifier", "guid"],
|
||||
"homepage": "https://github.com/ramsey/uuid",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ben Ramsey",
|
||||
"email": "ben@benramsey.com",
|
||||
"homepage": "https://benramsey.com"
|
||||
},
|
||||
{
|
||||
"name": "Marijn Huizendveld",
|
||||
"email": "marijn.huizendveld@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Thibaud Fabre",
|
||||
"email": "thibaud@aztech.io"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^5.4 | ^7 | ^8",
|
||||
"ext-json": "*",
|
||||
"paragonie/random_compat": "^1 | ^2 | 9.99.99",
|
||||
"symfony/polyfill-ctype": "^1.8"
|
||||
},
|
||||
"require-dev": {
|
||||
"codeception/aspect-mock": "^1 | ^2",
|
||||
"doctrine/annotations": "^1.2",
|
||||
"goaop/framework": "1.0.0-alpha.2 | ^1 | ^2.1",
|
||||
"jakub-onderka/php-parallel-lint": "^1",
|
||||
"mockery/mockery": "^0.9.11 | ^1",
|
||||
"moontoast/math": "^1.1",
|
||||
"paragonie/random-lib": "^2",
|
||||
"php-mock/php-mock-phpunit": "^0.3 | ^1.1",
|
||||
"phpunit/phpunit": "^4.8 | ^5.4 | ^6.5",
|
||||
"squizlabs/php_codesniffer": "^3.5"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-ctype": "Provides support for PHP Ctype functions",
|
||||
"ext-libsodium": "Provides the PECL libsodium extension for use with the SodiumRandomGenerator",
|
||||
"ext-openssl": "Provides the OpenSSL extension for use with the OpenSslGenerator",
|
||||
"ext-uuid": "Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator",
|
||||
"moontoast/math": "Provides support for converting UUID to 128-bit integer (in string form).",
|
||||
"ramsey/uuid-console": "A console application for generating UUIDs with ramsey/uuid",
|
||||
"ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type.",
|
||||
"paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter"
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.x-dev"
|
||||
}
|
||||
},
|
||||
"replace": {
|
||||
"rhumsaa/uuid": "self.version"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Ramsey\\Uuid\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/functions.php"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Ramsey\\Uuid\\Test\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "parallel-lint src tests",
|
||||
"phpcs": "phpcs src tests --standard=psr2 -sp --colors",
|
||||
"phpunit": "phpunit --verbose --colors=always",
|
||||
"phpunit-coverage": "phpunit --verbose --colors=always --coverage-html build/coverage",
|
||||
"test": [
|
||||
"@lint",
|
||||
"@phpcs",
|
||||
"@phpunit"
|
||||
]
|
||||
},
|
||||
"support": {
|
||||
"issues": "https://github.com/ramsey/uuid/issues",
|
||||
"rss": "https://github.com/ramsey/uuid/releases.atom",
|
||||
"source": "https://github.com/ramsey/uuid",
|
||||
"wiki": "https://github.com/ramsey/uuid/wiki"
|
||||
}
|
||||
}
|
||||
41
vendor/ramsey/uuid/src/BinaryUtils.php
vendored
Normal file
41
vendor/ramsey/uuid/src/BinaryUtils.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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 |= 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 |= $version << 12;
|
||||
|
||||
return $timeHi;
|
||||
}
|
||||
}
|
||||
54
vendor/ramsey/uuid/src/Builder/DefaultUuidBuilder.php
vendored
Normal file
54
vendor/ramsey/uuid/src/Builder/DefaultUuidBuilder.php
vendored
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
53
vendor/ramsey/uuid/src/Builder/DegradedUuidBuilder.php
vendored
Normal file
53
vendor/ramsey/uuid/src/Builder/DegradedUuidBuilder.php
vendored
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
34
vendor/ramsey/uuid/src/Builder/UuidBuilderInterface.php
vendored
Normal file
34
vendor/ramsey/uuid/src/Builder/UuidBuilderInterface.php
vendored
Normal file
@@ -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);
|
||||
}
|
||||
60
vendor/ramsey/uuid/src/Codec/CodecInterface.php
vendored
Normal file
60
vendor/ramsey/uuid/src/Codec/CodecInterface.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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\Exception\InvalidUuidStringException;
|
||||
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
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
public function decode($encodedUuid);
|
||||
|
||||
/**
|
||||
* Decodes a binary representation of a UUID into a UuidInterface object instance
|
||||
*
|
||||
* @param string $bytes
|
||||
* @return UuidInterface
|
||||
* @throws InvalidUuidStringException
|
||||
* @throws InvalidArgumentException if string has not 16 characters
|
||||
*/
|
||||
public function decodeBytes($bytes);
|
||||
}
|
||||
103
vendor/ramsey/uuid/src/Codec/GuidStringCodec.php
vendored
Normal file
103
vendor/ramsey/uuid/src/Codec/GuidStringCodec.php
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
<?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\Exception\InvalidUuidStringException;
|
||||
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
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
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
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
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];
|
||||
}
|
||||
}
|
||||
68
vendor/ramsey/uuid/src/Codec/OrderedTimeCodec.php
vendored
Normal file
68
vendor/ramsey/uuid/src/Codec/OrderedTimeCodec.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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
|
||||
* @throws InvalidArgumentException if string has not 16 characters
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
170
vendor/ramsey/uuid/src/Codec/StringCodec.php
vendored
Normal file
170
vendor/ramsey/uuid/src/Codec/StringCodec.php
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
<?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
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
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
|
||||
* @throws InvalidArgumentException if string has not 16 characters
|
||||
*/
|
||||
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
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
protected function extractComponents($encodedUuid)
|
||||
{
|
||||
$nameParsed = str_replace([
|
||||
'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 = [
|
||||
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 [
|
||||
'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)
|
||||
];
|
||||
}
|
||||
}
|
||||
108
vendor/ramsey/uuid/src/Codec/TimestampFirstCombCodec.php
vendored
Normal file
108
vendor/ramsey/uuid/src/Codec/TimestampFirstCombCodec.php
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<?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\Exception\InvalidUuidStringException;
|
||||
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
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
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
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
22
vendor/ramsey/uuid/src/Codec/TimestampLastCombCodec.php
vendored
Normal file
22
vendor/ramsey/uuid/src/Codec/TimestampLastCombCodec.php
vendored
Normal file
@@ -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\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
|
||||
{
|
||||
}
|
||||
54
vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php
vendored
Normal file
54
vendor/ramsey/uuid/src/Converter/Number/BigNumberConverter.php
vendored
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
58
vendor/ramsey/uuid/src/Converter/Number/DegradedNumberConverter.php
vendored
Normal file
58
vendor/ramsey/uuid/src/Converter/Number/DegradedNumberConverter.php
vendored
Normal file
@@ -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. '
|
||||
);
|
||||
}
|
||||
}
|
||||
48
vendor/ramsey/uuid/src/Converter/NumberConverterInterface.php
vendored
Normal file
48
vendor/ramsey/uuid/src/Converter/NumberConverterInterface.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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;
|
||||
|
||||
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present
|
||||
*/
|
||||
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
|
||||
* @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present
|
||||
*/
|
||||
public function toHex($integer);
|
||||
}
|
||||
59
vendor/ramsey/uuid/src/Converter/Time/BigNumberTimeConverter.php
vendored
Normal file
59
vendor/ramsey/uuid/src/Converter/Time/BigNumberTimeConverter.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?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 [
|
||||
'low' => substr($uuidTimeHex, 8),
|
||||
'mid' => substr($uuidTimeHex, 4, 4),
|
||||
'hi' => substr($uuidTimeHex, 0, 4),
|
||||
];
|
||||
}
|
||||
}
|
||||
42
vendor/ramsey/uuid/src/Converter/Time/DegradedTimeConverter.php
vendored
Normal file
42
vendor/ramsey/uuid/src/Converter/Time/DegradedTimeConverter.php
vendored
Normal file
@@ -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 if called on a 32-bit system and `Moontoast\Math\BigNumber` is not present
|
||||
*/
|
||||
public function calculateTime($seconds, $microSeconds)
|
||||
{
|
||||
throw new UnsatisfiedDependencyException(
|
||||
'When calling ' . __METHOD__ . ' on a 32-bit system, '
|
||||
. 'Moontoast\Math\BigNumber must be present.'
|
||||
);
|
||||
}
|
||||
}
|
||||
47
vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php
vendored
Normal file
47
vendor/ramsey/uuid/src/Converter/Time/PhpTimeConverter.php
vendored
Normal file
@@ -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 [
|
||||
'low' => sprintf('%08x', $uuidTime & 0xffffffff),
|
||||
'mid' => sprintf('%04x', ($uuidTime >> 32) & 0xffff),
|
||||
'hi' => sprintf('%04x', ($uuidTime >> 48) & 0x0fff),
|
||||
];
|
||||
}
|
||||
}
|
||||
37
vendor/ramsey/uuid/src/Converter/TimeConverterInterface.php
vendored
Normal file
37
vendor/ramsey/uuid/src/Converter/TimeConverterInterface.php
vendored
Normal file
@@ -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\Converter;
|
||||
|
||||
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @throws UnsatisfiedDependencyException if called on a 32-bit system and
|
||||
* `Moontoast\Math\BigNumber` is not present
|
||||
* @link http://tools.ietf.org/html/rfc4122#section-4.2.2
|
||||
*/
|
||||
public function calculateTime($seconds, $microSeconds);
|
||||
}
|
||||
116
vendor/ramsey/uuid/src/DegradedUuid.php
vendored
Normal file
116
vendor/ramsey/uuid/src/DegradedUuid.php
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
<?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 DateTime;
|
||||
use Moontoast\Math\BigNumber;
|
||||
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
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getDateTime()
|
||||
{
|
||||
if ($this->getVersion() != 1) {
|
||||
throw new UnsupportedOperationException('Not a time-based UUID');
|
||||
}
|
||||
|
||||
$time = $this->converter->fromHex($this->getTimestampHex());
|
||||
|
||||
$ts = new 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'
|
||||
);
|
||||
}
|
||||
}
|
||||
24
vendor/ramsey/uuid/src/Exception/InvalidUuidStringException.php
vendored
Normal file
24
vendor/ramsey/uuid/src/Exception/InvalidUuidStringException.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that the parsed UUID string is invalid.
|
||||
*/
|
||||
class InvalidUuidStringException extends InvalidArgumentException
|
||||
{
|
||||
}
|
||||
25
vendor/ramsey/uuid/src/Exception/UnsatisfiedDependencyException.php
vendored
Normal file
25
vendor/ramsey/uuid/src/Exception/UnsatisfiedDependencyException.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that the requested operation has dependencies that have not
|
||||
* been satisfied.
|
||||
*/
|
||||
class UnsatisfiedDependencyException extends RuntimeException
|
||||
{
|
||||
}
|
||||
24
vendor/ramsey/uuid/src/Exception/UnsupportedOperationException.php
vendored
Normal file
24
vendor/ramsey/uuid/src/Exception/UnsupportedOperationException.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that the requested operation is not supported.
|
||||
*/
|
||||
class UnsupportedOperationException extends RuntimeException
|
||||
{
|
||||
}
|
||||
335
vendor/ramsey/uuid/src/FeatureSet.php
vendored
Normal file
335
vendor/ramsey/uuid/src/FeatureSet.php
vendored
Normal file
@@ -0,0 +1,335 @@
|
||||
<?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();
|
||||
}
|
||||
|
||||
if ($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;
|
||||
}
|
||||
}
|
||||
91
vendor/ramsey/uuid/src/Generator/CombGenerator.php
vendored
Normal file
91
vendor/ramsey/uuid/src/Generator/CombGenerator.php
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
<?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 Exception;
|
||||
use InvalidArgumentException;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present
|
||||
* @throws InvalidArgumentException if length is not a positive integer
|
||||
* @throws Exception
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
141
vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php
vendored
Normal file
141
vendor/ramsey/uuid/src/Generator/DefaultTimeGenerator.php
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
<?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 Exception;
|
||||
use InvalidArgumentException;
|
||||
use Ramsey\Uuid\BinaryUtils;
|
||||
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
|
||||
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
|
||||
* @throws UnsatisfiedDependencyException if called on a 32-bit system and
|
||||
* `Moontoast\Math\BigNumber` is not present
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Exception if it was not possible to gather sufficient entropy
|
||||
*/
|
||||
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 = random_int(0, 0x3fff);
|
||||
}
|
||||
|
||||
// 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',
|
||||
[
|
||||
$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
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Exception
|
||||
*/
|
||||
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));
|
||||
}
|
||||
}
|
||||
45
vendor/ramsey/uuid/src/Generator/MtRandGenerator.php
vendored
Normal file
45
vendor/ramsey/uuid/src/Generator/MtRandGenerator.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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
|
||||
*
|
||||
* @deprecated The mt_rand() function is not a reliable source of randomness.
|
||||
* The default RandomBytesGenerator, which uses the random_bytes() function,
|
||||
* is recommended as the safest and most reliable source of randomness.
|
||||
* <em>This generator will be removed in ramsey/uuid 4.0.0.</em>
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
43
vendor/ramsey/uuid/src/Generator/OpenSslGenerator.php
vendored
Normal file
43
vendor/ramsey/uuid/src/Generator/OpenSslGenerator.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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.
|
||||
*
|
||||
* @deprecated The openssl_random_pseudo_bytes() function is not a reliable
|
||||
* source of randomness. The default RandomBytesGenerator, which uses the
|
||||
* random_bytes() function, is recommended as the safest and most reliable
|
||||
* source of randomness.
|
||||
* <em>This generator will be removed in ramsey/uuid 4.0.0.</em>
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
37
vendor/ramsey/uuid/src/Generator/PeclUuidRandomGenerator.php
vendored
Normal file
37
vendor/ramsey/uuid/src/Generator/PeclUuidRandomGenerator.php
vendored
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
38
vendor/ramsey/uuid/src/Generator/PeclUuidTimeGenerator.php
vendored
Normal file
38
vendor/ramsey/uuid/src/Generator/PeclUuidTimeGenerator.php
vendored
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
39
vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php
vendored
Normal file
39
vendor/ramsey/uuid/src/Generator/RandomBytesGenerator.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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 Exception;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @throws Exception if it was not possible to gather sufficient entropy
|
||||
*/
|
||||
public function generate($length)
|
||||
{
|
||||
return random_bytes($length);
|
||||
}
|
||||
}
|
||||
31
vendor/ramsey/uuid/src/Generator/RandomGeneratorFactory.php
vendored
Normal file
31
vendor/ramsey/uuid/src/Generator/RandomGeneratorFactory.php
vendored
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
37
vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php
vendored
Normal file
37
vendor/ramsey/uuid/src/Generator/RandomGeneratorInterface.php
vendored
Normal file
@@ -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;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Exception if it was not possible to gather sufficient entropy
|
||||
*/
|
||||
public function generate($length);
|
||||
}
|
||||
62
vendor/ramsey/uuid/src/Generator/RandomLibAdapter.php
vendored
Normal file
62
vendor/ramsey/uuid/src/Generator/RandomLibAdapter.php
vendored
Normal file
@@ -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 paragonie/random-lib library
|
||||
*
|
||||
* @link https://packagist.org/packages/paragonie/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 high-strength
|
||||
* generator to use when generating random binary data.
|
||||
*
|
||||
* @param Generator $generator An paragonie/random-lib `Generator`
|
||||
*/
|
||||
public function __construct(Generator $generator = null)
|
||||
{
|
||||
$this->generator = $generator;
|
||||
|
||||
if ($this->generator === null) {
|
||||
$factory = new Factory();
|
||||
|
||||
$this->generator = $factory->getHighStrengthGenerator();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
41
vendor/ramsey/uuid/src/Generator/SodiumRandomGenerator.php
vendored
Normal file
41
vendor/ramsey/uuid/src/Generator/SodiumRandomGenerator.php
vendored
Normal file
@@ -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;
|
||||
|
||||
/**
|
||||
* SodiumRandomGenerator provides functionality to generate strings of random
|
||||
* binary data using the PECL libsodium extension
|
||||
*
|
||||
* @deprecated As of PHP 7.2.0, the libsodium extension is bundled with PHP, and
|
||||
* the random_bytes() PHP function is now the recommended method for
|
||||
* generating random byes. The default RandomBytesGenerator uses the
|
||||
* random_bytes() function.
|
||||
* <em>This generator will be removed in ramsey/uuid 4.0.0.</em>
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
72
vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php
vendored
Normal file
72
vendor/ramsey/uuid/src/Generator/TimeGeneratorFactory.php
vendored
Normal file
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
43
vendor/ramsey/uuid/src/Generator/TimeGeneratorInterface.php
vendored
Normal file
43
vendor/ramsey/uuid/src/Generator/TimeGeneratorInterface.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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 Exception;
|
||||
use InvalidArgumentException;
|
||||
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @throws UnsatisfiedDependencyException if called on a 32-bit system and
|
||||
* `Moontoast\Math\BigNumber` is not present
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Exception if it was not possible to gather sufficient entropy
|
||||
*/
|
||||
public function generate($node = null, $clockSeq = null);
|
||||
}
|
||||
59
vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php
vendored
Normal file
59
vendor/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?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 Exception;
|
||||
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
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getNode()
|
||||
{
|
||||
foreach ($this->nodeProviders as $provider) {
|
||||
if ($node = $provider->getNode()) {
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
57
vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php
vendored
Normal file
57
vendor/ramsey/uuid/src/Provider/Node/RandomNodeProvider.php
vendored
Normal file
@@ -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 Exception;
|
||||
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
|
||||
* @throws Exception if it was not possible to gather sufficient entropy
|
||||
*/
|
||||
public function getNode()
|
||||
{
|
||||
$nodeBytes = random_bytes(6);
|
||||
|
||||
// Split the node bytes for math on 32-bit systems.
|
||||
$nodeMsb = substr($nodeBytes, 0, 3);
|
||||
$nodeLsb = substr($nodeBytes, 3);
|
||||
|
||||
// Set the multicast bit; see RFC 4122, section 4.5.
|
||||
$nodeMsb = hex2bin(
|
||||
str_pad(
|
||||
dechex(hexdec(bin2hex($nodeMsb)) | 0x010000),
|
||||
6,
|
||||
'0',
|
||||
STR_PAD_LEFT
|
||||
)
|
||||
);
|
||||
|
||||
// Recombine the node bytes.
|
||||
$node = $nodeMsb . $nodeLsb;
|
||||
|
||||
return str_pad(bin2hex($node), 12, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
128
vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php
vendored
Normal file
128
vendor/ramsey/uuid/src/Provider/Node/SystemNodeProvider.php
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
<?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 = [];
|
||||
|
||||
// first try a linux specific way
|
||||
$node = $this->getSysfs();
|
||||
|
||||
// Search the ifconfig output for all MAC addresses and return
|
||||
// the first one found
|
||||
if ($node === false) {
|
||||
if (preg_match_all($pattern, $this->getIfconfig(), $matches, PREG_PATTERN_ORDER)) {
|
||||
$node = $matches[1][0];
|
||||
}
|
||||
}
|
||||
if ($node !== false) {
|
||||
$node = str_replace([':', '-'], '', $node);
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the network interface configuration for the system
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @return string
|
||||
*/
|
||||
protected function getIfconfig()
|
||||
{
|
||||
if (strpos(strtolower(ini_get('disable_functions')), 'passthru') !== false) {
|
||||
return '';
|
||||
}
|
||||
|
||||
ob_start();
|
||||
switch (strtoupper(substr(constant('PHP_OS'), 0, 3))) {
|
||||
case 'WIN':
|
||||
passthru('ipconfig /all 2>&1');
|
||||
break;
|
||||
case 'DAR':
|
||||
passthru('ifconfig 2>&1');
|
||||
break;
|
||||
case 'FRE':
|
||||
passthru('netstat -i -f link 2>&1');
|
||||
break;
|
||||
case 'LIN':
|
||||
default:
|
||||
passthru('netstat -ie 2>&1');
|
||||
break;
|
||||
}
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns mac address from the first system interface via the sysfs interface
|
||||
*
|
||||
* @return string|bool
|
||||
*/
|
||||
protected function getSysfs()
|
||||
{
|
||||
$mac = false;
|
||||
|
||||
if (strtoupper(constant('PHP_OS')) === 'LINUX') {
|
||||
$addressPaths = glob('/sys/class/net/*/address', GLOB_NOSORT);
|
||||
|
||||
if (empty($addressPaths)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$macs = [];
|
||||
array_walk($addressPaths, function ($addressPath) use (&$macs) {
|
||||
if (is_readable($addressPath)) {
|
||||
$macs[] = file_get_contents($addressPath);
|
||||
}
|
||||
});
|
||||
|
||||
$macs = array_map('trim', $macs);
|
||||
|
||||
// remove invalid entries
|
||||
$macs = array_filter($macs, function ($mac) {
|
||||
return
|
||||
// localhost adapter
|
||||
$mac !== '00:00:00:00:00:00' &&
|
||||
// must match mac adress
|
||||
preg_match('/^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i', $mac);
|
||||
});
|
||||
|
||||
$mac = reset($macs);
|
||||
}
|
||||
|
||||
return $mac;
|
||||
}
|
||||
}
|
||||
32
vendor/ramsey/uuid/src/Provider/NodeProviderInterface.php
vendored
Normal file
32
vendor/ramsey/uuid/src/Provider/NodeProviderInterface.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @throws Exception if it was not possible to gather sufficient entropy
|
||||
*/
|
||||
public function getNode();
|
||||
}
|
||||
77
vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php
vendored
Normal file
77
vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?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 InvalidArgumentException;
|
||||
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;
|
||||
}
|
||||
}
|
||||
33
vendor/ramsey/uuid/src/Provider/Time/SystemTimeProvider.php
vendored
Normal file
33
vendor/ramsey/uuid/src/Provider/Time/SystemTimeProvider.php
vendored
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
29
vendor/ramsey/uuid/src/Provider/TimeProviderInterface.php
vendored
Normal file
29
vendor/ramsey/uuid/src/Provider/TimeProviderInterface.php
vendored
Normal file
@@ -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();
|
||||
}
|
||||
751
vendor/ramsey/uuid/src/Uuid.php
vendored
Normal file
751
vendor/ramsey/uuid/src/Uuid.php
vendored
Normal file
@@ -0,0 +1,751 @@
|
||||
<?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 DateTime;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\Exception\InvalidUuidStringException;
|
||||
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
|
||||
use Ramsey\Uuid\Exception\UnsupportedOperationException;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 1, 3, 4, and 5 UUIDs as specified in RFC 4122.
|
||||
*
|
||||
* If all you want is a unique ID, you should probably call `uuid1()` or `uuid4()`.
|
||||
* Note that `uuid1()` may compromise privacy since it creates a UUID containing
|
||||
* the computer’s network address. `uuid4()` creates a random UUID.
|
||||
*
|
||||
* @link http://tools.ietf.org/html/rfc4122
|
||||
* @link http://en.wikipedia.org/wiki/Universally_unique_identifier
|
||||
* @link http://docs.python.org/3/library/uuid.html
|
||||
* @link http://docs.oracle.com/javase/6/docs/api/java/util/UUID.html
|
||||
*/
|
||||
class Uuid implements UuidInterface
|
||||
{
|
||||
/**
|
||||
* When this namespace is specified, the name string is a fully-qualified domain name.
|
||||
* @link http://tools.ietf.org/html/rfc4122#appendix-C
|
||||
*/
|
||||
const NAMESPACE_DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
||||
|
||||
/**
|
||||
* When this namespace is specified, the name string is a URL.
|
||||
* @link http://tools.ietf.org/html/rfc4122#appendix-C
|
||||
*/
|
||||
const NAMESPACE_URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
||||
|
||||
/**
|
||||
* When this namespace is specified, the name string is an ISO OID.
|
||||
* @link http://tools.ietf.org/html/rfc4122#appendix-C
|
||||
*/
|
||||
const NAMESPACE_OID = '6ba7b812-9dad-11d1-80b4-00c04fd430c8';
|
||||
|
||||
/**
|
||||
* When this namespace is specified, the name string is an X.500 DN in DER or a text output format.
|
||||
* @link http://tools.ietf.org/html/rfc4122#appendix-C
|
||||
*/
|
||||
const NAMESPACE_X500 = '6ba7b814-9dad-11d1-80b4-00c04fd430c8';
|
||||
|
||||
/**
|
||||
* The nil UUID is special form of UUID that is specified to have all 128 bits set to zero.
|
||||
* @link http://tools.ietf.org/html/rfc4122#section-4.1.7
|
||||
*/
|
||||
const NIL = '00000000-0000-0000-0000-000000000000';
|
||||
|
||||
/**
|
||||
* Reserved for NCS compatibility.
|
||||
* @link http://tools.ietf.org/html/rfc4122#section-4.1.1
|
||||
*/
|
||||
const RESERVED_NCS = 0;
|
||||
|
||||
/**
|
||||
* Specifies the UUID layout given in RFC 4122.
|
||||
* @link http://tools.ietf.org/html/rfc4122#section-4.1.1
|
||||
*/
|
||||
const RFC_4122 = 2;
|
||||
|
||||
/**
|
||||
* Reserved for Microsoft compatibility.
|
||||
* @link http://tools.ietf.org/html/rfc4122#section-4.1.1
|
||||
*/
|
||||
const RESERVED_MICROSOFT = 6;
|
||||
|
||||
/**
|
||||
* Reserved for future definition.
|
||||
* @link http://tools.ietf.org/html/rfc4122#section-4.1.1
|
||||
*/
|
||||
const RESERVED_FUTURE = 7;
|
||||
|
||||
/**
|
||||
* Regular expression pattern for matching a valid UUID of any variant.
|
||||
*/
|
||||
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 1 (time-based) UUID object constant identifier
|
||||
*/
|
||||
const UUID_TYPE_TIME = 1;
|
||||
|
||||
/**
|
||||
* Version 2 (identifier-based) UUID object constant identifier
|
||||
*/
|
||||
const UUID_TYPE_IDENTIFIER = 2;
|
||||
|
||||
/**
|
||||
* Version 3 (name-based and hashed with MD5) UUID object constant identifier
|
||||
*/
|
||||
const UUID_TYPE_HASH_MD5 = 3;
|
||||
|
||||
/**
|
||||
* Version 4 (random) UUID object constant identifier
|
||||
*/
|
||||
const UUID_TYPE_RANDOM = 4;
|
||||
|
||||
/**
|
||||
* Version 5 (name-based and hashed with SHA1) UUID object constant identifier
|
||||
*/
|
||||
const UUID_TYPE_HASH_SHA1 = 5;
|
||||
|
||||
/**
|
||||
* The factory to use when creating UUIDs.
|
||||
* @var UuidFactoryInterface
|
||||
*/
|
||||
private static $factory = null;
|
||||
|
||||
/**
|
||||
* The codec to use when encoding or decoding UUID strings.
|
||||
* @var CodecInterface
|
||||
*/
|
||||
protected $codec;
|
||||
|
||||
/**
|
||||
* The fields that make up this UUID.
|
||||
*
|
||||
* This is initialized to the nil value.
|
||||
*
|
||||
* @var array
|
||||
* @see UuidInterface::getFieldsHex()
|
||||
*/
|
||||
protected $fields = [
|
||||
'time_low' => '00000000',
|
||||
'time_mid' => '0000',
|
||||
'time_hi_and_version' => '0000',
|
||||
'clock_seq_hi_and_reserved' => '00',
|
||||
'clock_seq_low' => '00',
|
||||
'node' => '000000000000',
|
||||
];
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
* ```
|
||||
* 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.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @return string
|
||||
* @link http://www.php.net/manual/en/language.oop5.magic.php#object.tostring
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this UUID object to a string when the object is serialized
|
||||
* with `json_encode()`
|
||||
*
|
||||
* @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()`
|
||||
*
|
||||
* @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 string $serialized
|
||||
* @link http://php.net/manual/en/class.serializable.php
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
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)
|
||||
{
|
||||
if ($this->getMostSignificantBitsHex() < $other->getMostSignificantBitsHex()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ($this->getMostSignificantBitsHex() > $other->getMostSignificantBitsHex()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ($this->getLeastSignificantBitsHex() < $other->getLeastSignificantBitsHex()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ($this->getLeastSignificantBitsHex() > $other->getLeastSignificantBitsHex()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function equals($other)
|
||||
{
|
||||
if (!$other instanceof UuidInterface) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->compareTo($other) == 0;
|
||||
}
|
||||
|
||||
public function getBytes()
|
||||
{
|
||||
return $this->codec->encodeBinary($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the high field of the clock sequence multiplexed with the variant
|
||||
* (bits 65-72 of the UUID).
|
||||
*
|
||||
* @return int Unsigned 8-bit integer value of clock_seq_hi_and_reserved
|
||||
*/
|
||||
public function getClockSeqHiAndReserved()
|
||||
{
|
||||
return hexdec($this->getClockSeqHiAndReservedHex());
|
||||
}
|
||||
|
||||
public function getClockSeqHiAndReservedHex()
|
||||
{
|
||||
return $this->fields['clock_seq_hi_and_reserved'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the low field of the clock sequence (bits 73-80 of the UUID).
|
||||
*
|
||||
* @return int Unsigned 8-bit integer value of clock_seq_low
|
||||
*/
|
||||
public function getClockSeqLow()
|
||||
{
|
||||
return hexdec($this->getClockSeqLowHex());
|
||||
}
|
||||
|
||||
public function getClockSeqLowHex()
|
||||
{
|
||||
return $this->fields['clock_seq_low'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the clock sequence value associated with this UUID.
|
||||
*
|
||||
* For UUID version 1, the clock sequence is used to help avoid
|
||||
* duplicates that could arise when the clock is set backwards in time
|
||||
* or if the node ID changes.
|
||||
*
|
||||
* For UUID version 3 or 5, the clock sequence is a 14-bit value
|
||||
* constructed from a name as described in RFC 4122, Section 4.3.
|
||||
*
|
||||
* For UUID version 4, clock sequence is a randomly or pseudo-randomly
|
||||
* generated 14-bit value as described in RFC 4122, Section 4.4.
|
||||
*
|
||||
* @return int Unsigned 14-bit integer value of clock sequence
|
||||
* @link http://tools.ietf.org/html/rfc4122#section-4.1.5
|
||||
*/
|
||||
public function getClockSequence()
|
||||
{
|
||||
return ($this->getClockSeqHiAndReserved() & 0x3f) << 8 | $this->getClockSeqLow();
|
||||
}
|
||||
|
||||
public function getClockSequenceHex()
|
||||
{
|
||||
return sprintf('%04x', $this->getClockSequence());
|
||||
}
|
||||
|
||||
public function getNumberConverter()
|
||||
{
|
||||
return $this->converter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getDateTime()
|
||||
{
|
||||
if ($this->getVersion() != 1) {
|
||||
throw new UnsupportedOperationException('Not a time-based UUID');
|
||||
}
|
||||
|
||||
$unixTime = ($this->getTimestamp() - 0x01b21dd213814000) / 1e7;
|
||||
$unixTime = number_format($unixTime, 0, '', '');
|
||||
|
||||
return new DateTime("@{$unixTime}");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 integer values
|
||||
* @link http://tools.ietf.org/html/rfc4122#section-4.1.2
|
||||
*/
|
||||
public function getFields()
|
||||
{
|
||||
return [
|
||||
'time_low' => $this->getTimeLow(),
|
||||
'time_mid' => $this->getTimeMid(),
|
||||
'time_hi_and_version' => $this->getTimeHiAndVersion(),
|
||||
'clock_seq_hi_and_reserved' => $this->getClockSeqHiAndReserved(),
|
||||
'clock_seq_low' => $this->getClockSeqLow(),
|
||||
'node' => $this->getNode(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getFieldsHex()
|
||||
{
|
||||
return $this->fields;
|
||||
}
|
||||
|
||||
public function getHex()
|
||||
{
|
||||
return str_replace('-', '', $this->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getInteger()
|
||||
{
|
||||
return $this->converter->fromHex($this->getHex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the least significant 64 bits of this UUID's 128 bit value.
|
||||
*
|
||||
* @return mixed Converted representation of the unsigned 64-bit integer value
|
||||
* @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present
|
||||
*/
|
||||
public function getLeastSignificantBits()
|
||||
{
|
||||
return $this->converter->fromHex($this->getLeastSignificantBitsHex());
|
||||
}
|
||||
|
||||
public function getLeastSignificantBitsHex()
|
||||
{
|
||||
return sprintf(
|
||||
'%02s%02s%012s',
|
||||
$this->fields['clock_seq_hi_and_reserved'],
|
||||
$this->fields['clock_seq_low'],
|
||||
$this->fields['node']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the most significant 64 bits of this UUID's 128 bit value.
|
||||
*
|
||||
* @return mixed Converted representation of the unsigned 64-bit integer value
|
||||
* @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present
|
||||
*/
|
||||
public function getMostSignificantBits()
|
||||
{
|
||||
return $this->converter->fromHex($this->getMostSignificantBitsHex());
|
||||
}
|
||||
|
||||
public function getMostSignificantBitsHex()
|
||||
{
|
||||
return sprintf(
|
||||
'%08s%04s%04s',
|
||||
$this->fields['time_low'],
|
||||
$this->fields['time_mid'],
|
||||
$this->fields['time_hi_and_version']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 int Unsigned 48-bit integer value of node
|
||||
* @link http://tools.ietf.org/html/rfc4122#section-4.1.6
|
||||
*/
|
||||
public function getNode()
|
||||
{
|
||||
return hexdec($this->getNodeHex());
|
||||
}
|
||||
|
||||
public function getNodeHex()
|
||||
{
|
||||
return $this->fields['node'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the high field of the timestamp multiplexed with the version
|
||||
* number (bits 49-64 of the UUID).
|
||||
*
|
||||
* @return int Unsigned 16-bit integer value of time_hi_and_version
|
||||
*/
|
||||
public function getTimeHiAndVersion()
|
||||
{
|
||||
return hexdec($this->getTimeHiAndVersionHex());
|
||||
}
|
||||
|
||||
public function getTimeHiAndVersionHex()
|
||||
{
|
||||
return $this->fields['time_hi_and_version'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the low field of the timestamp (the first 32 bits of the UUID).
|
||||
*
|
||||
* @return int Unsigned 32-bit integer value of time_low
|
||||
*/
|
||||
public function getTimeLow()
|
||||
{
|
||||
return hexdec($this->getTimeLowHex());
|
||||
}
|
||||
|
||||
public function getTimeLowHex()
|
||||
{
|
||||
return $this->fields['time_low'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the middle field of the timestamp (bits 33-48 of the UUID).
|
||||
*
|
||||
* @return int Unsigned 16-bit integer value of time_mid
|
||||
*/
|
||||
public function getTimeMid()
|
||||
{
|
||||
return hexdec($this->getTimeMidHex());
|
||||
}
|
||||
|
||||
public function getTimeMidHex()
|
||||
{
|
||||
return $this->fields['time_mid'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 int Unsigned 60-bit integer 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 getTimestamp()
|
||||
{
|
||||
if ($this->getVersion() != 1) {
|
||||
throw new UnsupportedOperationException('Not a time-based UUID');
|
||||
}
|
||||
|
||||
return hexdec($this->getTimestampHex());
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getTimestampHex()
|
||||
{
|
||||
if ($this->getVersion() != 1) {
|
||||
throw new UnsupportedOperationException('Not a time-based UUID');
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'%03x%04s%08s',
|
||||
($this->getTimeHiAndVersion() & 0x0fff),
|
||||
$this->fields['time_mid'],
|
||||
$this->fields['time_low']
|
||||
);
|
||||
}
|
||||
|
||||
public function getUrn()
|
||||
{
|
||||
return 'urn:uuid:' . $this->toString();
|
||||
}
|
||||
|
||||
public function getVariant()
|
||||
{
|
||||
$clockSeq = $this->getClockSeqHiAndReserved();
|
||||
|
||||
if (0 === ($clockSeq & 0x80)) {
|
||||
return self::RESERVED_NCS;
|
||||
}
|
||||
|
||||
if (0 === ($clockSeq & 0x40)) {
|
||||
return self::RFC_4122;
|
||||
}
|
||||
|
||||
if (0 === ($clockSeq & 0x20)) {
|
||||
return self::RESERVED_MICROSOFT;
|
||||
}
|
||||
|
||||
return self::RESERVED_FUTURE;
|
||||
}
|
||||
|
||||
public function getVersion()
|
||||
{
|
||||
if ($this->getVariant() == self::RFC_4122) {
|
||||
return (int) (($this->getTimeHiAndVersion() >> 12) & 0x0f);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return $this->codec->encode($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently set factory used to create UUIDs.
|
||||
*
|
||||
* @return UuidFactoryInterface
|
||||
*/
|
||||
public static function getFactory()
|
||||
{
|
||||
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 UuidInterface
|
||||
* @throws InvalidUuidStringException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function fromBytes($bytes)
|
||||
{
|
||||
return self::getFactory()->fromBytes($bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a UUID from the string standard representation.
|
||||
*
|
||||
* @param string $name A string that specifies a UUID
|
||||
* @return UuidInterface
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
public static function fromString($name)
|
||||
{
|
||||
return self::getFactory()->fromString($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a UUID from a 128-bit integer string.
|
||||
*
|
||||
* @param string $integer String representation of 128-bit integer
|
||||
* @return UuidInterface
|
||||
* @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
public static function fromInteger($integer)
|
||||
{
|
||||
return self::getFactory()->fromInteger($integer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string is a valid UUID.
|
||||
*
|
||||
* @param string $uuid The string UUID to test
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isValid($uuid)
|
||||
{
|
||||
$uuid = str_replace(['urn:', 'uuid:', '{', '}'], '', $uuid);
|
||||
|
||||
if ($uuid == self::NIL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!preg_match('/' . self::VALID_PATTERN . '/D', $uuid)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @throws UnsatisfiedDependencyException if called on a 32-bit system and
|
||||
* `Moontoast\Math\BigNumber` is not present
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Exception if it was not possible to gather sufficient entropy
|
||||
*/
|
||||
public static function uuid1($node = null, $clockSeq = null)
|
||||
{
|
||||
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).
|
||||
*
|
||||
* @param string|UuidInterface $ns The UUID namespace in which to create the named UUID
|
||||
* @param string $name The name to create a UUID for
|
||||
* @return UuidInterface
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
public static function uuid3($ns, $name)
|
||||
{
|
||||
return self::getFactory()->uuid3($ns, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a version 4 (random) UUID.
|
||||
*
|
||||
* @return UuidInterface
|
||||
* @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function uuid4()
|
||||
{
|
||||
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).
|
||||
*
|
||||
* @param string|UuidInterface $ns The UUID namespace in which to create the named UUID
|
||||
* @param string $name The name to create a UUID for
|
||||
* @return UuidInterface
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
public static function uuid5($ns, $name)
|
||||
{
|
||||
return self::getFactory()->uuid5($ns, $name);
|
||||
}
|
||||
}
|
||||
315
vendor/ramsey/uuid/src/UuidFactory.php
vendored
Normal file
315
vendor/ramsey/uuid/src/UuidFactory.php
vendored
Normal file
@@ -0,0 +1,315 @@
|
||||
<?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\InvalidUuidStringException;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function fromBytes($bytes)
|
||||
{
|
||||
return $this->codec->decodeBytes($bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function fromString($uuid)
|
||||
{
|
||||
$uuid = strtolower($uuid);
|
||||
return $this->codec->decode($uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function fromInteger($integer)
|
||||
{
|
||||
$hex = $this->numberConverter->toHex($integer);
|
||||
$hex = str_pad($hex, 32, '0', STR_PAD_LEFT);
|
||||
|
||||
return $this->fromString($hex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function uuid1($node = null, $clockSeq = null)
|
||||
{
|
||||
$bytes = $this->timeGenerator->generate($node, $clockSeq);
|
||||
$hex = bin2hex($bytes);
|
||||
|
||||
return $this->uuidFromHashedName($hex, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function uuid3($ns, $name)
|
||||
{
|
||||
return $this->uuidFromNsAndName($ns, $name, 3, 'md5');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
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
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
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 = [
|
||||
'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);
|
||||
}
|
||||
}
|
||||
108
vendor/ramsey/uuid/src/UuidFactoryInterface.php
vendored
Normal file
108
vendor/ramsey/uuid/src/UuidFactoryInterface.php
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<?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 Exception;
|
||||
use InvalidArgumentException;
|
||||
use Ramsey\Uuid\Exception\InvalidUuidStringException;
|
||||
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
|
||||
|
||||
/**
|
||||
* 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|null $node A 48-bit number representing the hardware address
|
||||
* This number may be represented as an integer or a hexadecimal string.
|
||||
* @param int|null $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
|
||||
* @throws UnsatisfiedDependencyException if called on a 32-bit system and
|
||||
* `Moontoast\Math\BigNumber` is not present
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Exception if it was not possible to gather sufficient entropy
|
||||
*/
|
||||
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|UuidInterface $ns The UUID namespace in which to create the named UUID
|
||||
* @param string $name The name to create a UUID for
|
||||
* @return UuidInterface
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
public function uuid3($ns, $name);
|
||||
|
||||
/**
|
||||
* Generate a version 4 (random) UUID.
|
||||
*
|
||||
* @return UuidInterface
|
||||
* @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Exception
|
||||
*/
|
||||
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|UuidInterface $ns The UUID namespace in which to create the named UUID
|
||||
* @param string $name The name to create a UUID for
|
||||
* @return UuidInterface
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
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
|
||||
* @throws InvalidUuidStringException
|
||||
* @throws InvalidArgumentException if string has not 16 characters
|
||||
*/
|
||||
public function fromBytes($bytes);
|
||||
|
||||
/**
|
||||
* Creates a UUID from the string standard representation
|
||||
*
|
||||
* @param string $uuid A string representation of a UUID
|
||||
* @return UuidInterface
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
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
|
||||
* @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
public function fromInteger($integer);
|
||||
}
|
||||
274
vendor/ramsey/uuid/src/UuidInterface.php
vendored
Normal file
274
vendor/ramsey/uuid/src/UuidInterface.php
vendored
Normal file
@@ -0,0 +1,274 @@
|
||||
<?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 DateTime;
|
||||
use JsonSerializable;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
|
||||
use Ramsey\Uuid\Exception\UnsupportedOperationException;
|
||||
use Serializable;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @throws UnsatisfiedDependencyException if called in a 32-bit system and
|
||||
* `Moontoast\Math\BigNumber` is not present
|
||||
*/
|
||||
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
|
||||
* @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present
|
||||
*/
|
||||
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();
|
||||
}
|
||||
78
vendor/ramsey/uuid/src/functions.php
vendored
Normal file
78
vendor/ramsey/uuid/src/functions.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
namespace Ramsey\Uuid;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use Ramsey\Uuid\Exception\InvalidUuidStringException;
|
||||
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
|
||||
|
||||
/**
|
||||
* Generate a version 1 UUID from a host ID, sequence number, and the current time.
|
||||
*
|
||||
* @param int|string|null $node A 48-bit number representing the hardware address
|
||||
* This number may be represented as an integer or a hexadecimal string.
|
||||
* @param int|null $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
|
||||
* @throws UnsatisfiedDependencyException if called on a 32-bit system and
|
||||
* `Moontoast\Math\BigNumber` is not present
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Exception if it was not possible to gather sufficient entropy
|
||||
*/
|
||||
function v1($node = null, $clockSeq = null)
|
||||
{
|
||||
return Uuid::uuid1($node, $clockSeq)->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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|UuidInterface $ns The UUID namespace in which to create the named UUID
|
||||
* @param string $name The name to create a UUID for
|
||||
* @return string
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
function v3($ns, $name)
|
||||
{
|
||||
return Uuid::uuid3($ns, $name)->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a version 4 (random) UUID.
|
||||
*
|
||||
* @return string
|
||||
* @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Exception
|
||||
*/
|
||||
function v4()
|
||||
{
|
||||
return Uuid::uuid4()->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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|UuidInterface $ns The UUID namespace in which to create the named UUID
|
||||
* @param string $name The name to create a UUID for
|
||||
* @return string
|
||||
* @throws InvalidUuidStringException
|
||||
*/
|
||||
function v5($ns, $name)
|
||||
{
|
||||
return Uuid::uuid5($ns, $name)->toString();
|
||||
}
|
||||
Reference in New Issue
Block a user