| 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 transition($transition) |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @param $transition |
||
| 63 | * @return bool |
||
| 64 | * @throws \SM\SMException|\Illuminate\Container\EntryNotFoundException |
||
| 65 | */ |
||
| 66 | public function transitionAllowed($transition) |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @return mixed|\SM\StateMachine\StateMachine |
||
| 73 | * @throws \Illuminate\Container\EntryNotFoundException |
||
| 74 | */ |
||
| 75 | public function stateMachine() |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @return string |
||
| 86 | */ |
||
| 87 | protected function getGraph() |
||
| 91 | } |
||
| 92 |
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
Idableprovides a methodequalsIdthat 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.