| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* This file is part of the ramsey/uuid library |
| 5 |
* |
| 6 |
* For the full copyright and license information, please view the LICENSE |
| 7 |
* file that was distributed with this source code. |
| 8 |
* |
| 9 |
* @copyright Copyright (c) Ben Ramsey <[email protected]> |
| 10 |
* @license http://opensource.org/licenses/MIT MIT |
| 11 |
*/ |
| 12 |
declare (strict_types=1); |
| 13 |
namespace Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Rfc4122; |
| 14 |
|
| 15 |
use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Codec\CodecInterface; |
| 16 |
use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Converter\NumberConverterInterface; |
| 17 |
use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Converter\TimeConverterInterface; |
| 18 |
use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Exception\InvalidArgumentException; |
| 19 |
use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface; |
| 20 |
use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Uuid; |
| 21 |
/** |
| 22 |
* Custom format, or version 8, UUIDs provide an RFC-compatible format for experimental or vendor-specific uses |
| 23 |
* |
| 24 |
* The only requirement for version 8 UUIDs is that the version and variant bits must be set. Otherwise, implementations |
| 25 |
* are free to set the other bits according to their needs. As a result, the uniqueness of version 8 UUIDs is |
| 26 |
* implementation-specific and should not be assumed. |
| 27 |
* |
| 28 |
* @link https://www.rfc-editor.org/rfc/rfc9562#section-5.8 RFC 9562, 5.8. UUID Version 8 |
| 29 |
* |
| 30 |
* @immutable |
| 31 |
*/ |
| 32 |
final class UuidV8 extends Uuid implements UuidInterface |
| 33 |
{ |
| 34 |
/** |
| 35 |
* Creates a version 8 (custom format) UUID |
| 36 |
* |
| 37 |
* @param Rfc4122FieldsInterface $fields The fields from which to construct a UUID |
| 38 |
* @param NumberConverterInterface $numberConverter The number converter to use for converting hex values to/from integers |
| 39 |
* @param CodecInterface $codec The codec to use when encoding or decoding UUID strings |
| 40 |
* @param TimeConverterInterface $timeConverter The time converter to use for converting timestamps extracted from a |
| 41 |
* UUID to unix timestamps |
| 42 |
*/ |
| 43 |
public function __construct(Rfc4122FieldsInterface $fields, NumberConverterInterface $numberConverter, CodecInterface $codec, TimeConverterInterface $timeConverter) |
| 44 |
{ |
| 45 |
if ($fields->getVersion() !== Uuid::UUID_TYPE_CUSTOM) { |
| 46 |
throw new InvalidArgumentException('Fields used to create a UuidV8 must represent a version 8 (custom format) UUID'); |
| 47 |
} |
| 48 |
parent::__construct($fields, $numberConverter, $codec, $timeConverter); |
| 49 |
} |
| 50 |
} |
| 51 |
|