Debian Codegraph @

vendor/ramsey/uuid/src/UuidInterface.php

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