Total Complexity | 6 |
Total Lines | 71 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
9 | abstract class StateMetadata |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $current; |
||
15 | |||
16 | /** |
||
17 | * @param string $initial The initial state name |
||
18 | */ |
||
19 | 15 | public function __construct($initial) |
|
20 | { |
||
21 | 15 | Assert::string($initial); |
|
22 | 15 | $this->current = $initial; |
|
23 | 15 | } |
|
24 | |||
25 | /** |
||
26 | * Returns the state workflow configuration. |
||
27 | * |
||
28 | * @param StateBuilder $builder |
||
29 | */ |
||
30 | abstract protected function configure(StateBuilder $builder); |
||
31 | |||
32 | 18 | private function getMachine() |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * @param string $name |
||
42 | * @param mixed $context |
||
43 | * @param TransitionCallback|null $callback |
||
44 | * |
||
45 | * @return StateMetadata |
||
46 | */ |
||
47 | 12 | final public function transit($name, $context, TransitionCallback $callback = null) |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * @param string $attribute |
||
56 | * |
||
57 | * @return bool |
||
58 | */ |
||
59 | 6 | final public function hasAttribute($attribute) |
|
60 | { |
||
61 | 6 | return $this->getMachine()->hasAttribute($attribute); |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * @param string $state |
||
66 | * |
||
67 | * @return bool |
||
68 | */ |
||
69 | 16 | final public function isInState($state) |
|
72 | } |
||
73 | |||
74 | /** |
||
75 | * @return string |
||
76 | */ |
||
77 | 1 | final public function getCurrent() |
|
82 |