Builder
3 years ago
Codec
3 years ago
Converter
3 years ago
Exception
3 years ago
Fields
3 years ago
Generator
3 years ago
Guid
3 years ago
Lazy
3 years ago
Math
3 years ago
Nonstandard
3 years ago
Provider
3 years ago
Rfc4122
3 years ago
Type
3 years ago
Validator
3 years ago
BinaryUtils.php
3 years ago
DegradedUuid.php
3 years ago
DeprecatedUuidInterface.php
3 years ago
DeprecatedUuidMethodsTrait.php
3 years ago
FeatureSet.php
3 years ago
Uuid.php
3 years ago
UuidFactory.php
3 years ago
UuidFactoryInterface.php
3 years ago
UuidInterface.php
3 years ago
functions.php
3 years ago
UuidInterface.php
100 lines
| 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 |
| 88 | * |
| 89 | * @psalm-return non-empty-string |
| 90 | */ |
| 91 | public function toString(): string; |
| 92 | |
| 93 | /** |
| 94 | * Casts the UUID to the string standard representation |
| 95 | * |
| 96 | * @psalm-return non-empty-string |
| 97 | */ |
| 98 | public function __toString(): string; |
| 99 | } |
| 100 |