| Total Complexity | 4 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | trait FlowIdTrait |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * This Flow / Node id |
||
| 23 | * |
||
| 24 | * @var string |
||
| 25 | */ |
||
| 26 | protected $id; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Current nonce, fully valid within each thread |
||
| 30 | * |
||
| 31 | * @var int |
||
| 32 | */ |
||
| 33 | protected static $nonce = 0; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * We need to reset the id when being cloned |
||
| 37 | * to guarantee immutable uniqueness |
||
| 38 | */ |
||
| 39 | public function __clone() |
||
| 45 | } |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Return the immutable unique Flow / Node id |
||
| 50 | * Since this method is not used in the actual |
||
| 51 | * flow execution loop, but only when an interruption |
||
| 52 | * is raised, it's not a performance issue to add an if. |
||
| 53 | * And it's more convenient to lazy generate as this |
||
| 54 | * trait does not need any init/construct logic. |
||
| 55 | * |
||
| 56 | * @throws Exception |
||
| 57 | * |
||
| 58 | * @return string Immutable unique id |
||
| 59 | */ |
||
| 60 | public function getId(): string |
||
| 69 |