Total Complexity | 9 |
Total Lines | 73 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | class Transition |
||
13 | { |
||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $name; |
||
18 | |||
19 | /** |
||
20 | * @var State[] |
||
21 | */ |
||
22 | protected $fromStates; |
||
23 | |||
24 | /** |
||
25 | * @var State |
||
26 | */ |
||
27 | protected $toState; |
||
28 | |||
29 | /** |
||
30 | * @var callable|null |
||
31 | */ |
||
32 | protected $checker; |
||
33 | |||
34 | /** |
||
35 | * Transition constructor. |
||
36 | * |
||
37 | * @param string $name |
||
38 | * @param array|State $from |
||
39 | * @param State $to |
||
40 | * @param callable $checker |
||
41 | */ |
||
42 | 12 | public function __construct(string $name, $from, State $to, $checker = null) |
|
43 | { |
||
44 | 12 | $this->name = $name; |
|
45 | 12 | $this->fromStates = !is_array($from) ? [$from] : $from; |
|
46 | 12 | $this->toState = $to; |
|
47 | 12 | $this->checker = $checker; |
|
48 | 12 | } |
|
49 | |||
50 | /** |
||
51 | * @return State[] |
||
52 | */ |
||
53 | 2 | public function getFromStates(): array |
|
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return State |
||
60 | */ |
||
61 | 4 | public function getToState(): State |
|
62 | { |
||
63 | 4 | return $this->toState; |
|
64 | } |
||
65 | |||
66 | /** |
||
67 | * @param StatefulInterface $stateful |
||
68 | * @param array $parameters |
||
69 | * |
||
70 | * @return bool |
||
71 | */ |
||
72 | 5 | public function can(StatefulInterface $stateful, array $parameters = []): bool |
|
85 | } |
||
86 | } |
||
87 |