| 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 |
* Version 5 UUIDs are named-based, using a combination of a namespace and name that are hashed into a 128-bit unsigned |
| 23 |
* integer using the SHA1 hashing algorithm |
| 24 |
* |
| 25 |
* @link https://www.rfc-editor.org/rfc/rfc9562#section-5.5 RFC 9562, 5.5. UUID Version 5 |
| 26 |
* |
| 27 |
* @immutable |
| 28 |
*/ |
| 29 |
final class UuidV5 extends Uuid implements UuidInterface |
| 30 |
{ |
| 31 |
/** |
| 32 |
* Creates a version 5 (name-based, SHA1-hashed) UUID |
| 33 |
* |
| 34 |
* @param Rfc4122FieldsInterface $fields The fields from which to construct a UUID |
| 35 |
* @param NumberConverterInterface $numberConverter The number converter to use for converting hex values to/from integers |
| 36 |
* @param CodecInterface $codec The codec to use when encoding or decoding UUID strings |
| 37 |
* @param TimeConverterInterface $timeConverter The time converter to use for converting timestamps extracted from a |
| 38 |
* UUID to unix timestamps |
| 39 |
*/ |
| 40 |
public function __construct(Rfc4122FieldsInterface $fields, NumberConverterInterface $numberConverter, CodecInterface $codec, TimeConverterInterface $timeConverter) |
| 41 |
{ |
| 42 |
if ($fields->getVersion() !== Uuid::UUID_TYPE_HASH_SHA1) { |
| 43 |
throw new InvalidArgumentException('Fields used to create a UuidV5 must represent a version 5 (named-based, SHA1-hashed) UUID'); |
| 44 |
} |
| 45 |
parent::__construct($fields, $numberConverter, $codec, $timeConverter); |
| 46 |
} |
| 47 |
} |
| 48 |
|