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
 * Unix Epoch time, or version 7, UUIDs include a timestamp in milliseconds
26
 * since the Unix Epoch, along with random bytes
27
 *
28
 * @link https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis-00#section-5.7 UUID Version 7
29
 *
30
 * @psalm-immutable
31
 */
32
final class UuidV7 extends Uuid implements UuidInterface
33
{
34
    use TimeTrait;
35
 
36
    /**
37
     * Creates a version 7 (Unix Epoch time) UUID
38
     *
39
     * @param Rfc4122FieldsInterface $fields The fields from which to construct a UUID
40
     * @param NumberConverterInterface $numberConverter The number converter to use
41
     *     for converting hex values to/from integers
42
     * @param CodecInterface $codec The codec to use when encoding or decoding
43
     *     UUID strings
44
     * @param TimeConverterInterface $timeConverter The time converter to use
45
     *     for converting timestamps extracted from a UUID to unix timestamps
46
     */
47
    public function __construct(
48
        Rfc4122FieldsInterface $fields,
49
        NumberConverterInterface $numberConverter,
50
        CodecInterface $codec,
51
        TimeConverterInterface $timeConverter
52
    ) {
53
        if ($fields->getVersion() !== Uuid::UUID_TYPE_UNIX_TIME) {
54
            throw new InvalidArgumentException(
55
                'Fields used to create a UuidV7 must represent a '
56
                . 'version 7 (Unix Epoch time) UUID'
57
            );
58
        }
59
 
60
        parent::__construct($fields, $numberConverter, $codec, $timeConverter);
61
    }
62
}