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