Total Complexity | 6 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
8 | abstract class StateMetadata |
||
9 | { |
||
10 | /** |
||
11 | * @var string |
||
12 | */ |
||
13 | protected $current; |
||
14 | |||
15 | /** |
||
16 | * @param string $initial The initial state name |
||
17 | */ |
||
18 | 15 | public function __construct(string $initial) |
|
19 | { |
||
20 | 15 | $this->current = $initial; |
|
21 | 15 | } |
|
22 | |||
23 | /** |
||
24 | * Returns the state workflow configuration. |
||
25 | * |
||
26 | * @param StateBuilder $builder |
||
27 | */ |
||
28 | abstract protected function configure(StateBuilder $builder): void; |
||
29 | |||
30 | 18 | private function getMachine(): StateMachine |
|
36 | } |
||
37 | |||
38 | /** |
||
39 | * @param string $name |
||
40 | * @param mixed $context |
||
41 | * @param TransitionCallback|null $callback |
||
42 | * |
||
43 | * @return static |
||
44 | */ |
||
45 | 12 | final public function transit(string $name, $context, TransitionCallback $callback = null): StateMetadata |
|
50 | } |
||
51 | |||
52 | 6 | final public function hasAttribute(string $attribute): bool |
|
53 | { |
||
54 | 6 | return $this->getMachine()->hasAttribute($attribute); |
|
55 | } |
||
56 | |||
57 | 16 | final public function isInState(string $state): bool |
|
60 | } |
||
61 | |||
62 | 1 | final public function getCurrent(): string |
|
67 |