| 1 | <?php |
||
| 15 | trait FlowIdTrait |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * This Flow / Node id |
||
| 19 | * |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | protected $id; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Current nonce, fully valid within each thread |
||
| 26 | * |
||
| 27 | * @var int |
||
| 28 | */ |
||
| 29 | protected static $nonce = 0; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * We need to reset the id when being cloned |
||
| 33 | * to guarantee immutable uniqueness |
||
| 34 | */ |
||
| 35 | public function __clone() |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Return the immutable unique Flow / Node id |
||
| 42 | * Since this method is not used in the actual |
||
| 43 | * flow execution loop, but only when an interruption |
||
| 44 | * is raised, it's not a performance issue to add an if. |
||
| 45 | * And it's more convenient to lazy generate as this |
||
| 46 | * trait does not need any init/construct logic. |
||
| 47 | * |
||
| 48 | * @return string immutable unique id |
||
| 49 | */ |
||
| 50 | public function getId() |
||
| 68 | } |
||
| 69 |