PHP Class izzum\statemachine\Identifier

A statemachine is always uniquely identified by the combination of an entity id and a machine name (that provides the relation to the statemachine the entity is governed by). the machine name should be a 'machine readable' string, since it will be stored in different backends and might be used as a key there (eg: in redis). The entity id is something that uniquely identifies a domain model. Probably something that is stored in your application, like a primary key in a table, a GUID or a hash. This object thus stores the minimum data needed from other processes in your application domain to succesfully work with the statemachine.
Author: Rolf Vreijdenberger
Show file Open project: rolfvreijdenberger/izzum-statemachine Class Usage Examples

Protected Properties

Property Type Description
$entity_id string an entity id that represents the unique identifier for an application domain specific object (entity) like 'Order', 'Customer' etc.
$machine_name string this is the name of the statemachine itself and is used in conjunction with the entity_id to define what a statemachine is about.

Public Methods

Method Description
__construct ( mixed $entity_id, string $machine_name ) Constructor
__toString ( ) : string
getEntityId ( ) : string gets the entity id that represents the unique identifier for the application domain specific model.
getId ( boolean $readable = false ) : string get the unique identifier representation for an Identifier, which consists of the machine name and the entity_id in parseable form.
getMachine ( ) : string gets the statemachine name that handles the entity
setEntityId ( mixed $entity_id ) set the id of the domain specific entity (it will internally be converted to a string)
toString ( ) : string

Method Details

__construct() public method

Constructor
public __construct ( mixed $entity_id, string $machine_name )
$entity_id mixed the id of the domain specific entity (it will internally be converted to a string)
$machine_name string the name of the statemachine (eg: 'order')

__toString() public method

public __toString ( ) : string
return string

getEntityId() public method

gets the entity id that represents the unique identifier for the application domain specific model.
public getEntityId ( ) : string
return string

getId() public method

get the unique identifier representation for an Identifier, which consists of the machine name and the entity_id in parseable form.
public getId ( boolean $readable = false ) : string
$readable boolean human readable or not. defaults to false
return string

getMachine() public method

gets the statemachine name that handles the entity
public getMachine ( ) : string
return string

setEntityId() public method

set the id of the domain specific entity (it will internally be converted to a string)
public setEntityId ( mixed $entity_id )
$entity_id mixed

toString() public method

public toString ( ) : string
return string

Property Details

$entity_id protected property

an entity id that represents the unique identifier for an application domain specific object (entity) like 'Order', 'Customer' etc.
protected string $entity_id
return string

$machine_name protected property

this is the name of the statemachine itself and is used in conjunction with the entity_id to define what a statemachine is about.
protected string $machine_name
return string