\Pho\FrameworkID

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.

Summary

Methods
Properties
Constants
distance()
bin()
generate()
fromString()
root()
equals()
__toString()
toString()
No public properties found
BitLength
ByteLength
header()
$value
N/A
No private methods found
No private properties found
N/A

Constants

BitLength

BitLength = 128

ByteLength

ByteLength = self::BitLength / 8

Properties

$value

$value : string

Pho ID in string.

In Hex format

Type

string

Methods

distance()

distance(  $another_id) 

{@inheritdoc}

Parameters

$another_id
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 1275

bin()

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 1275

generate()

generate(\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.

Parameters

\Pho\Lib\Graph\EntityInterface $entity
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 1275

Returns

\Pho\Lib\Graph\ID

Random ID in object format.

fromString()

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.

Parameters

string $id

Must consist of 32 hexadecimal characters.

Throws

\Pho\Lib\Graph\Exceptions\MalformedIDException

thrown when the given ID is not a valid UUIDv4

Returns

\Pho\Lib\Graph\ID

The ID in object format

root()

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 1275

Returns

\Pho\Lib\Graph\ID

equals()

equals(\Pho\Lib\Graph\ID  $id) : boolean

Verifies identicality

Parameters

\Pho\Lib\Graph\ID $id
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 1275

Returns

boolean

__toString()

__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

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 1275

Returns

string

toString()

toString() : string

Stringifies the object.

Returns a string representation of the object for portability. Use with PHP type-casting as follows; (string) $ID_object

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 1275

Returns

string

header()

header(\Pho\Lib\Graph\EntityInterface  $entity) : array

Fetches the entity header.

Entity headers will be as follows:

  • 0: Graph
  • 1: Unidentified Node
  • 2: SubGraph Node
  • 3: Framework\Graph Node
  • 4: Actor Node
  • 5: Object Node
  • 6: Unidentified Edge
  • 7: Read Edge
  • 8: Write Edge
  • 9: Subscribe Edge
  • 10: Mention Edge
  • 11: Unidentified

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.

Parameters

\Pho\Lib\Graph\EntityInterface $entity
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 1275

Returns

array —

An array of two ints (actually hexadecimals)