| 1 |
<?php |
| 2 |
/** |
| 3 |
* This file is part of the ramsey/uuid library |
| 4 |
* |
| 5 |
* For the full copyright and license information, please view the LICENSE |
| 6 |
* file that was distributed with this source code. |
| 7 |
* |
| 8 |
* @copyright Copyright (c) Ben Ramsey <[email protected]> |
| 9 |
* @license http://opensource.org/licenses/MIT MIT |
| 10 |
* @link https://benramsey.com/projects/ramsey-uuid/ Documentation |
| 11 |
* @link https://packagist.org/packages/ramsey/uuid Packagist |
| 12 |
* @link https://github.com/ramsey/uuid GitHub |
| 13 |
*/ |
| 14 |
|
| 15 |
namespace Ramsey\Uuid; |
| 16 |
|
| 17 |
use Exception; |
| 18 |
use InvalidArgumentException; |
| 19 |
use Ramsey\Uuid\Exception\InvalidUuidStringException; |
| 20 |
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; |
| 21 |
|
| 22 |
/** |
| 23 |
* UuidFactoryInterface defines common functionality all `UuidFactory` instances |
| 24 |
* must implement |
| 25 |
*/ |
| 26 |
interface UuidFactoryInterface |
| 27 |
{ |
| 28 |
/** |
| 29 |
* Generate a version 1 UUID from a host ID, sequence number, and the current time. |
| 30 |
* |
| 31 |
* @param int|string|null $node A 48-bit number representing the hardware address |
| 32 |
* This number may be represented as an integer or a hexadecimal string. |
| 33 |
* @param int|null $clockSeq A 14-bit number used to help avoid duplicates that |
| 34 |
* could arise when the clock is set backwards in time or if the node ID |
| 35 |
* changes. |
| 36 |
* @return UuidInterface |
| 37 |
* @throws UnsatisfiedDependencyException if called on a 32-bit system and |
| 38 |
* `Moontoast\Math\BigNumber` is not present |
| 39 |
* @throws InvalidArgumentException |
| 40 |
* @throws Exception if it was not possible to gather sufficient entropy |
| 41 |
*/ |
| 42 |
public function uuid1($node = null, $clockSeq = null); |
| 43 |
|
| 44 |
/** |
| 45 |
* Generate a version 3 UUID based on the MD5 hash of a namespace identifier |
| 46 |
* (which is a UUID) and a name (which is a string). |
| 47 |
* |
| 48 |
* @param string|UuidInterface $ns The UUID namespace in which to create the named UUID |
| 49 |
* @param string $name The name to create a UUID for |
| 50 |
* @return UuidInterface |
| 51 |
* @throws InvalidUuidStringException |
| 52 |
*/ |
| 53 |
public function uuid3($ns, $name); |
| 54 |
|
| 55 |
/** |
| 56 |
* Generate a version 4 (random) UUID. |
| 57 |
* |
| 58 |
* @return UuidInterface |
| 59 |
* @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present |
| 60 |
* @throws InvalidArgumentException |
| 61 |
* @throws Exception |
| 62 |
*/ |
| 63 |
public function uuid4(); |
| 64 |
|
| 65 |
/** |
| 66 |
* Generate a version 5 UUID based on the SHA-1 hash of a namespace |
| 67 |
* identifier (which is a UUID) and a name (which is a string). |
| 68 |
* |
| 69 |
* @param string|UuidInterface $ns The UUID namespace in which to create the named UUID |
| 70 |
* @param string $name The name to create a UUID for |
| 71 |
* @return UuidInterface |
| 72 |
* @throws InvalidUuidStringException |
| 73 |
*/ |
| 74 |
public function uuid5($ns, $name); |
| 75 |
|
| 76 |
/** |
| 77 |
* Creates a UUID from a byte string. |
| 78 |
* |
| 79 |
* @param string $bytes A 16-byte string representation of a UUID |
| 80 |
* @return UuidInterface |
| 81 |
* @throws InvalidUuidStringException |
| 82 |
* @throws InvalidArgumentException if string has not 16 characters |
| 83 |
*/ |
| 84 |
public function fromBytes($bytes); |
| 85 |
|
| 86 |
/** |
| 87 |
* Creates a UUID from the string standard representation |
| 88 |
* |
| 89 |
* @param string $uuid A string representation of a UUID |
| 90 |
* @return UuidInterface |
| 91 |
* @throws InvalidUuidStringException |
| 92 |
*/ |
| 93 |
public function fromString($uuid); |
| 94 |
|
| 95 |
/** |
| 96 |
* Creates a `Uuid` from an integer representation |
| 97 |
* |
| 98 |
* The integer representation may be a real integer, a string integer, or |
| 99 |
* an integer representation supported by a configured number converter. |
| 100 |
* |
| 101 |
* @param mixed $integer The integer to use when creating a `Uuid` from an |
| 102 |
* integer; may be of any type understood by the configured number converter |
| 103 |
* @return UuidInterface |
| 104 |
* @throws UnsatisfiedDependencyException if `Moontoast\Math\BigNumber` is not present |
| 105 |
* @throws InvalidUuidStringException |
| 106 |
*/ |
| 107 |
public function fromInteger($integer); |
| 108 |
} |