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;
16
 
17
use DateTimeInterface;
18
use Ramsey\Uuid\Type\Hexadecimal;
19
use Ramsey\Uuid\Type\Integer as IntegerObject;
20
use Ramsey\Uuid\Validator\ValidatorInterface;
21
 
22
/**
23
 * UuidFactoryInterface defines common functionality all `UuidFactory` instances
24
 * must implement
25
 */
26
interface UuidFactoryInterface
27
{
28
    /**
29
     * Creates a UUID from a byte string
30
     *
31
     * @param string $bytes A binary string
32
     *
33
     * @return UuidInterface A UuidInterface instance created from a binary
34
     *     string representation
35
     *
36
     * @psalm-pure
37
     */
38
    public function fromBytes(string $bytes): UuidInterface;
39
 
40
    /**
41
     * Creates a UUID from a DateTimeInterface instance
42
     *
43
     * @param DateTimeInterface $dateTime The date and time
44
     * @param Hexadecimal|null $node A 48-bit number representing the hardware
45
     *     address
46
     * @param int|null $clockSeq A 14-bit number used to help avoid duplicates
47
     *     that could arise when the clock is set backwards in time or if the
48
     *     node ID changes
49
     *
50
     * @return UuidInterface A UuidInterface instance that represents a
51
     *     version 1 UUID created from a DateTimeInterface instance
52
     */
53
    public function fromDateTime(
54
        DateTimeInterface $dateTime,
55
        ?Hexadecimal $node = null,
56
        ?int $clockSeq = null
57
    ): UuidInterface;
58
 
59
    /**
60
     * Creates a UUID from a 128-bit integer string
61
     *
62
     * @param string $integer String representation of 128-bit integer
63
     *
64
     * @return UuidInterface A UuidInterface instance created from the string
65
     *     representation of a 128-bit integer
66
     *
67
     * @psalm-pure
68
     */
69
    public function fromInteger(string $integer): UuidInterface;
70
 
71
    /**
72
     * Creates a UUID from the string standard representation
73
     *
74
     * @param string $uuid A hexadecimal string
75
     *
76
     * @return UuidInterface A UuidInterface instance created from a hexadecimal
77
     *     string representation
78
     *
79
     * @psalm-pure
80
     */
81
    public function fromString(string $uuid): UuidInterface;
82
 
83
    /**
84
     * Returns the validator to use for the factory
85
     *
86
     * @psalm-mutation-free
87
     */
88
    public function getValidator(): ValidatorInterface;
89
 
90
    /**
91
     * Returns a version 1 (Gregorian time) UUID from a host ID, sequence number,
92
     * and the current time
93
     *
94
     * @param Hexadecimal|int|string|null $node A 48-bit number representing the
95
     *     hardware address; this number may be represented as an integer or a
96
     *     hexadecimal string
97
     * @param int|null $clockSeq A 14-bit number used to help avoid duplicates
98
     *     that could arise when the clock is set backwards in time or if the
99
     *     node ID changes
100
     *
101
     * @return UuidInterface A UuidInterface instance that represents a
102
     *     version 1 UUID
103
     */
104
    public function uuid1($node = null, ?int $clockSeq = null): UuidInterface;
105
 
106
    /**
107
     * Returns a version 2 (DCE Security) UUID from a local domain, local
108
     * identifier, host ID, clock sequence, and the current time
109
     *
110
     * @param int $localDomain The local domain to use when generating bytes,
111
     *     according to DCE Security
112
     * @param IntegerObject|null $localIdentifier The local identifier for the
113
     *     given domain; this may be a UID or GID on POSIX systems, if the local
114
     *     domain is person or group, or it may be a site-defined identifier
115
     *     if the local domain is org
116
     * @param Hexadecimal|null $node A 48-bit number representing the hardware
117
     *     address
118
     * @param int|null $clockSeq A 14-bit number used to help avoid duplicates
119
     *     that could arise when the clock is set backwards in time or if the
120
     *     node ID changes
121
     *
122
     * @return UuidInterface A UuidInterface instance that represents a
123
     *     version 2 UUID
124
     */
125
    public function uuid2(
126
        int $localDomain,
127
        ?IntegerObject $localIdentifier = null,
128
        ?Hexadecimal $node = null,
129
        ?int $clockSeq = null
130
    ): UuidInterface;
131
 
132
    /**
133
     * Returns a version 3 (name-based) UUID based on the MD5 hash of a
134
     * namespace ID and a name
135
     *
136
     * @param string|UuidInterface $ns The namespace (must be a valid UUID)
137
     * @param string $name The name to use for creating a UUID
138
     *
139
     * @return UuidInterface A UuidInterface instance that represents a
140
     *     version 3 UUID
141
     *
142
     * @psalm-pure
143
     */
144
    public function uuid3($ns, string $name): UuidInterface;
145
 
146
    /**
147
     * Returns a version 4 (random) UUID
148
     *
149
     * @return UuidInterface A UuidInterface instance that represents a
150
     *     version 4 UUID
151
     */
152
    public function uuid4(): UuidInterface;
153
 
154
    /**
155
     * Returns a version 5 (name-based) UUID based on the SHA-1 hash of a
156
     * namespace ID and a name
157
     *
158
     * @param string|UuidInterface $ns The namespace (must be a valid UUID)
159
     * @param string $name The name to use for creating a UUID
160
     *
161
     * @return UuidInterface A UuidInterface instance that represents a
162
     *     version 5 UUID
163
     *
164
     * @psalm-pure
165
     */
166
    public function uuid5($ns, string $name): UuidInterface;
167
 
168
    /**
169
     * Returns a version 6 (reordered time) UUID from a host ID, sequence number,
170
     * and the current time
171
     *
172
     * @param Hexadecimal|null $node A 48-bit number representing the hardware
173
     *     address
174
     * @param int|null $clockSeq A 14-bit number used to help avoid duplicates
175
     *     that could arise when the clock is set backwards in time or if the
176
     *     node ID changes
177
     *
178
     * @return UuidInterface A UuidInterface instance that represents a
179
     *     version 6 UUID
180
     */
181
    public function uuid6(?Hexadecimal $node = null, ?int $clockSeq = null): UuidInterface;
182
}