\Pho\Lib\GraphEntityWorkerInterface

An worker interface for EntityTrait.

Graphs are mathematical structures used to model pairwise relations between objects. Entities is a Pho concept used to represent the commonalities between the most atomic graph elements, Nodes and Edges.

Summary

Methods
Constants
id()
label()
isA()
attributes()
destroy()
toArray()
equals()
emit()
init()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

id()

id() : \Pho\Lib\Graph\ID

Returns the unique id of the entity.

The IDs in Pho Kernel are in the form of cryptographically secure UUIDv4. Even at scale of billions of nodes and edges, the chances of collision is identical to zero. The IDs are immutable, therefore there is not a setter method provided.

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

The ID

label()

label() : string

Returns the label of the entity.

Provides a more developer-friendly way of getting class name. Labels are immutable.

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 —

The label in all lowercase.

isA()

isA(string  $class_name) : boolean

A boolean method that verifies if the entity extends or is the given class.

This method is a helper and works identical to using $node instanceof $class_name or `$edge instanceof $class_name

Make sure the $class_name parameter is namespace-safe with get_class() method orthe special ::class constant (http://php.net/manual/en/language.oop5.constants.php).

Parameters

string $class_name
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

attributes()

attributes() : string|array|null|boolean

Retrieves the attribute bag associated with this entity.

Once you fetch the bag, you can add new values by assigning values to the object; $entity->attributes()->my_value = 2

Similarly you can fetch values by accessing the properties of the bag object directly. You can use the PHP isset() function to check if they exist or unset() if the attribute needs to be deleted.

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|array|null|boolean

destroy()

destroy() : void

If the purpose is just to free up memory by getting rid of unused entities, you can use PHP's built-in ```unset()``` method.

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

toArray()

toArray() : array

Converts the object to array

Used for serialization/unserialization. Converts internal object properties into a simple format to help with reconstruction.

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 —

The object in array format.

equals()

equals(\Pho\Lib\Graph\EntityInterface  $entity) : boolean

Checks if given entity is the same as this object.

Parameters

\Pho\Lib\Graph\EntityInterface $entity

Entity to check equality

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

emit()

emit(string  $signal, array  $params = array()) : boolean

Broadcasts a signal

Enables an event-driven architecture.

Parameters

string $signal
array $params
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

init()

init() : self

Initializer

Must be called when the object is initialized. Either manually or after deserialization.

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

self