1 | <?php |
||
23 | class Identifier { |
||
24 | const NULL_ENTITY_ID = "-1"; |
||
25 | const NULL_STATEMACHINE = 'null-machine'; |
||
26 | |||
27 | /** |
||
28 | * an entity id that represents the unique identifier for an application |
||
29 | * domain specific object (entity) like 'Order', 'Customer' etc. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $entity_id; |
||
34 | |||
35 | /** |
||
36 | * the statemachine that governs the state behaviour for this entity (eg |
||
37 | * 'order'). |
||
38 | * this is the name of the statemachine itself and is used in conjunction |
||
39 | * with the entity_id to define what a statemachine is about. |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $machine_name; |
||
44 | |||
45 | /** |
||
46 | * Constructor |
||
47 | * |
||
48 | * @param mixed $entity_id |
||
49 | * the id of the domain specific entity (it will internally be |
||
50 | * converted to a string) |
||
51 | * @param string $machine_name |
||
52 | * the name of the statemachine (eg: 'order') |
||
53 | */ |
||
54 | 92 | public function __construct($entity_id, $machine_name) |
|
61 | |||
62 | /** |
||
63 | * gets the statemachine name that handles the entity |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | 51 | public function getMachine() |
|
71 | |||
72 | /** |
||
73 | * set the id of the domain specific entity (it will internally be converted to a string) |
||
74 | * @param mixed $entity_id |
||
75 | */ |
||
76 | 92 | public function setEntityId($entity_id) |
|
80 | |||
81 | /** |
||
82 | * gets the entity id that represents the unique identifier for the |
||
83 | * application domain specific model. |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | 43 | public function getEntityId() |
|
91 | |||
92 | /** |
||
93 | * get the unique identifier representation for an Identifier, which |
||
94 | * consists of the machine name and the entity_id in parseable form. |
||
95 | * |
||
96 | * @param boolean $readable |
||
97 | * human readable or not. defaults to false |
||
98 | * @return string |
||
99 | */ |
||
100 | 31 | public function getId($readable = false) |
|
109 | |||
110 | /** |
||
111 | * |
||
112 | * @return string |
||
113 | */ |
||
114 | 3 | public function toString() |
|
118 | |||
119 | /** |
||
120 | * |
||
121 | * @return string |
||
122 | */ |
||
123 | 3 | public function __toString() |
|
127 | } |
||
128 |