1 | <?php |
||
8 | trait Statable |
||
9 | { |
||
10 | /** |
||
11 | * @var StateMachine |
||
12 | */ |
||
13 | protected $SM; |
||
14 | |||
15 | /** |
||
16 | * @return \Illuminate\Database\Eloquent\Model |
||
17 | */ |
||
18 | public function stateHistory() |
||
22 | |||
23 | /** |
||
24 | * @param array $transitionData |
||
25 | */ |
||
26 | public function addHistoryLine(array $transitionData) |
||
33 | |||
34 | /** |
||
35 | * @return int|null |
||
36 | */ |
||
37 | public function getActorId() |
||
41 | |||
42 | /** |
||
43 | * @return mixed|string |
||
44 | * @throws \Illuminate\Container\EntryNotFoundException |
||
45 | */ |
||
46 | public function stateIs() |
||
50 | |||
51 | /** |
||
52 | * @param $transition |
||
53 | * @return bool |
||
54 | * @throws \SM\SMException|\Illuminate\Container\EntryNotFoundException |
||
55 | */ |
||
56 | public function apply($transition) |
||
63 | |||
64 | /** |
||
65 | * @param $transition |
||
66 | * @return bool |
||
67 | * @throws \SM\SMException|\Illuminate\Container\EntryNotFoundException |
||
68 | */ |
||
69 | public function canApply($transition) |
||
73 | |||
74 | /** |
||
75 | * @return mixed|\SM\StateMachine\StateMachine |
||
76 | * @throws \Illuminate\Container\EntryNotFoundException |
||
77 | */ |
||
78 | public function stateMachine() |
||
86 | |||
87 | /** |
||
88 | * @return string |
||
89 | */ |
||
90 | protected function getGraph() |
||
94 | |||
95 | /** |
||
96 | * @return bool |
||
97 | */ |
||
98 | protected function saveBeforeTransition() |
||
102 | } |
||
103 |
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.