| 1 | <?php |
||
| 5 | trait Session |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Make a session var name for. |
||
| 9 | * |
||
| 10 | * @param null $name |
||
| 11 | * |
||
| 12 | * @return mixed |
||
| 13 | */ |
||
| 14 | protected function makeSessionVarName($name = null) |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Get a session var value. |
||
| 21 | * |
||
| 22 | * @param null $var |
||
| 23 | * |
||
| 24 | * @return mixed |
||
| 25 | */ |
||
| 26 | public function sessionGet($var = null) |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Put a var value to the current session. |
||
| 35 | * |
||
| 36 | * @param $var |
||
| 37 | * @param $value |
||
| 38 | * |
||
| 39 | * @return mixed |
||
| 40 | */ |
||
| 41 | protected function sessionPut($var, $value) |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Forget a session var. |
||
| 53 | * |
||
| 54 | * @param null $var |
||
| 55 | */ |
||
| 56 | protected function sessionForget($var = null) |
||
| 62 | } |
||
| 63 |
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.