BitLength
BitLength = 128
Immutable, cryptographically secure identifier
Pho IDs are immutable and come in the format of cryptographically secure, similarly to UUIDv4, though not the same.
Pho IDs are used to define all graph entities, e.g nodes and edges. It is 16 bytes (128 bits) long similar to UUID, but the first byte is reserved to determine entity type, while the UUID variants are omitted. Hence, Pho ID provides 15 bytes of randomness.
The Graph ID defaults to nil (00000000000000000000000000000000), or 32 chars
of 0. It may may be called with ID::root()
Even at scale of billions of nodes and edges, the chances of collision is identical to zero.
You can generate a new ID with $id_object = ID::generate($entity)
,
where $entity is any Pho entity, and fetch its string representation with
PHP type-casting; (string) $id_object
.
distance( $another_id)
{@inheritdoc}
$another_id |
bin()
{@inheritDoc}
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275generate(\Pho\Lib\Graph\EntityInterface $entity) : \Pho\Lib\Graph\ID
Generates a cryptographically secure random ID for internal use.
Pho ID does not conform to UUID standards. It is similar to UUID v4, however it does not use the same variants at same locations. Instead, the first byte is reserved for entity type, and the remaining 15 is used for randomness.
\Pho\Lib\Graph\EntityInterface | $entity |
Random ID in object format.
fromString(string $id) : \Pho\Lib\Graph\ID
Loads a Pho ID with the given string
Checks the validity of the string and throws an exception if it is not valid.
string | $id | Must consist of 32 hexadecimal characters. |
thrown when the given ID is not a valid UUIDv4
The ID in object format
root() : \Pho\Lib\Graph\ID
Retrieves the root ID
Root ID is the ID of the Graph. It doesn't conform with regular ID requirements (namely UUID) and it is just a period (.)
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275equals(\Pho\Lib\Graph\ID $id) : boolean
Verifies identicality
\Pho\Lib\Graph\ID | $id |
__toString() : string
{@internal}
Stringifies the object.
Returns a string representation of the object for portability.
Use with PHP
type-casting
as follows; (string) $ID_object
toString() : string
Stringifies the object.
Returns a string representation of the object for portability.
Use with PHP
type-casting
as follows; (string) $ID_object
header(\Pho\Lib\Graph\EntityInterface $entity) : array
Fetches the entity header.
Entity headers will be as follows:
This method may be overriden by packages at higher levels. The purpose of headers is to enable easy/fast classification of entitities by looking up the first byte of the UUID.
\Pho\Lib\Graph\EntityInterface | $entity |
An array of two ints (actually hexadecimals)