1 | <?php |
||
9 | trait Statable |
||
10 | { |
||
11 | /** |
||
12 | * @var StateMachine |
||
13 | */ |
||
14 | protected $SM; |
||
15 | |||
16 | /** |
||
17 | * @return \Illuminate\Database\Eloquent\Model |
||
18 | */ |
||
19 | public function stateHistory() |
||
26 | |||
27 | /** |
||
28 | * @param array $transitionData |
||
29 | */ |
||
30 | public function addHistoryLine(array $transitionData) |
||
37 | |||
38 | /** |
||
39 | * @return int|null |
||
40 | */ |
||
41 | public function getActorId() |
||
45 | |||
46 | /** |
||
47 | * @return mixed|string |
||
48 | * @throws \Illuminate\Container\EntryNotFoundException |
||
49 | */ |
||
50 | public function stateIs() |
||
54 | |||
55 | /** |
||
56 | * @param $transition |
||
57 | * @param bool $soft |
||
58 | * @param array $context |
||
59 | * @return bool |
||
60 | * @throws \Illuminate\Container\EntryNotFoundException |
||
61 | * @throws \SM\SMException |
||
62 | */ |
||
63 | public function apply($transition, $soft = false, $context = []) |
||
71 | |||
72 | /** |
||
73 | * @param $transition |
||
74 | * @param array $context |
||
75 | * @return bool |
||
76 | * @throws \Illuminate\Container\EntryNotFoundException |
||
77 | * @throws \SM\SMException |
||
78 | */ |
||
79 | public function canApply($transition, $context = []) |
||
83 | |||
84 | /** |
||
85 | * @return mixed|\Sebdesign\SM\StateMachine\StateMachine |
||
86 | * @throws \Illuminate\Container\EntryNotFoundException |
||
87 | */ |
||
88 | public function stateMachine() |
||
96 | |||
97 | /** |
||
98 | * @return string |
||
99 | */ |
||
100 | protected function getGraph() |
||
104 | |||
105 | /** |
||
106 | * @return bool |
||
107 | */ |
||
108 | protected function saveBeforeTransition() |
||
112 | } |
||
113 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.