| 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 JsonSerializable;
|
|
|
18 |
use Ramsey\Uuid\Fields\FieldsInterface;
|
|
|
19 |
use Ramsey\Uuid\Type\Hexadecimal;
|
|
|
20 |
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
|
|
21 |
use Serializable;
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
* A UUID is a universally unique identifier adhering to an agreed-upon
|
|
|
25 |
* representation format and standard for generation
|
|
|
26 |
*
|
|
|
27 |
* @psalm-immutable
|
|
|
28 |
*/
|
|
|
29 |
interface UuidInterface extends
|
|
|
30 |
DeprecatedUuidInterface,
|
|
|
31 |
JsonSerializable,
|
|
|
32 |
Serializable
|
|
|
33 |
{
|
|
|
34 |
/**
|
|
|
35 |
* Returns -1, 0, or 1 if the UUID is less than, equal to, or greater than
|
|
|
36 |
* the other UUID
|
|
|
37 |
*
|
|
|
38 |
* The first of two UUIDs is greater than the second if the most
|
|
|
39 |
* significant field in which the UUIDs differ is greater for the first
|
|
|
40 |
* UUID.
|
|
|
41 |
*
|
|
|
42 |
* * Q. What's the value of being able to sort UUIDs?
|
|
|
43 |
* * A. Use them as keys in a B-Tree or similar mapping.
|
|
|
44 |
*
|
|
|
45 |
* @param UuidInterface $other The UUID to compare
|
|
|
46 |
*
|
|
|
47 |
* @return int -1, 0, or 1 if the UUID is less than, equal to, or greater than $other
|
|
|
48 |
*/
|
|
|
49 |
public function compareTo(UuidInterface $other): int;
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* Returns true if the UUID is equal to the provided object
|
|
|
53 |
*
|
|
|
54 |
* The result is true if and only if the argument is not null, is a UUID
|
|
|
55 |
* object, has the same variant, and contains the same value, bit for bit,
|
|
|
56 |
* as the UUID.
|
|
|
57 |
*
|
|
|
58 |
* @param object|null $other An object to test for equality with this UUID
|
|
|
59 |
*
|
|
|
60 |
* @return bool True if the other object is equal to this UUID
|
|
|
61 |
*/
|
|
|
62 |
public function equals(?object $other): bool;
|
|
|
63 |
|
|
|
64 |
/**
|
|
|
65 |
* Returns the binary string representation of the UUID
|
|
|
66 |
*
|
|
|
67 |
* @psalm-return non-empty-string
|
|
|
68 |
*/
|
|
|
69 |
public function getBytes(): string;
|
|
|
70 |
|
|
|
71 |
/**
|
|
|
72 |
* Returns the fields that comprise this UUID
|
|
|
73 |
*/
|
|
|
74 |
public function getFields(): FieldsInterface;
|
|
|
75 |
|
|
|
76 |
/**
|
|
|
77 |
* Returns the hexadecimal representation of the UUID
|
|
|
78 |
*/
|
|
|
79 |
public function getHex(): Hexadecimal;
|
|
|
80 |
|
|
|
81 |
/**
|
|
|
82 |
* Returns the integer representation of the UUID
|
|
|
83 |
*/
|
|
|
84 |
public function getInteger(): IntegerObject;
|
|
|
85 |
|
|
|
86 |
/**
|
|
|
87 |
* Returns the string standard representation of the UUID as a URN
|
|
|
88 |
*
|
|
|
89 |
* @link http://en.wikipedia.org/wiki/Uniform_Resource_Name Uniform Resource Name
|
|
|
90 |
* @link https://tools.ietf.org/html/rfc4122#section-3 RFC 4122, § 3: Namespace Registration Template
|
|
|
91 |
*/
|
|
|
92 |
public function getUrn(): string;
|
|
|
93 |
|
|
|
94 |
/**
|
|
|
95 |
* Returns the string standard representation of the UUID
|
|
|
96 |
*
|
|
|
97 |
* @psalm-return non-empty-string
|
|
|
98 |
*/
|
|
|
99 |
public function toString(): string;
|
|
|
100 |
|
|
|
101 |
/**
|
|
|
102 |
* Casts the UUID to the string standard representation
|
|
|
103 |
*
|
|
|
104 |
* @psalm-return non-empty-string
|
|
|
105 |
*/
|
|
|
106 |
public function __toString(): string;
|
|
|
107 |
}
|