Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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 <ben@benramsey.com>
10
 * @license http://opensource.org/licenses/MIT MIT
11
 */
12
 
13
declare(strict_types=1);
14
 
15
namespace Ramsey\Uuid\Rfc4122;
16
 
17
use Ramsey\Uuid\Codec\CodecInterface;
18
use Ramsey\Uuid\Converter\NumberConverterInterface;
19
use Ramsey\Uuid\Converter\TimeConverterInterface;
20
use Ramsey\Uuid\Exception\InvalidArgumentException;
21
use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface;
22
use Ramsey\Uuid\Uuid;
23
 
24
/**
25
 * Version 8, Custom UUIDs provide an RFC 4122 compatible format for
26
 * experimental or vendor-specific uses
27
 *
28
 * The only requirement for version 8 UUIDs is that the version and variant bits
29
 * must be set. Otherwise, implementations are free to set the other bits
30
 * according to their needs. As a result, the uniqueness of version 8 UUIDs is
31
 * implementation-specific and should not be assumed.
32
 *
33
 * @link https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis-00#section-5.8 UUID Version 8
34
 *
35
 * @psalm-immutable
36
 */
37
final class UuidV8 extends Uuid implements UuidInterface
38
{
39
    /**
40
     * Creates a version 8 (custom) UUID
41
     *
42
     * @param Rfc4122FieldsInterface $fields The fields from which to construct a UUID
43
     * @param NumberConverterInterface $numberConverter The number converter to use
44
     *     for converting hex values to/from integers
45
     * @param CodecInterface $codec The codec to use when encoding or decoding
46
     *     UUID strings
47
     * @param TimeConverterInterface $timeConverter The time converter to use
48
     *     for converting timestamps extracted from a UUID to unix timestamps
49
     */
50
    public function __construct(
51
        Rfc4122FieldsInterface $fields,
52
        NumberConverterInterface $numberConverter,
53
        CodecInterface $codec,
54
        TimeConverterInterface $timeConverter
55
    ) {
56
        if ($fields->getVersion() !== Uuid::UUID_TYPE_CUSTOM) {
57
            throw new InvalidArgumentException(
58
                'Fields used to create a UuidV8 must represent a '
59
                . 'version 8 (custom) UUID'
60
            );
61
        }
62
 
63
        parent::__construct($fields, $numberConverter, $codec, $timeConverter);
64
    }
65
}