| 1 | <?php |
||
| 18 | trait HasCommand |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * Define which command must be ran with the request |
||
| 22 | * @param mixed $command Command to be ran before actual request is performed |
||
| 23 | * @return Configuration|mixed |
||
| 24 | */ |
||
| 25 | public function commandsRequest($command = null) |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Define which command must be ran after the request |
||
| 32 | * @param mixed $command Command to be ran after actual request is performed |
||
| 33 | * @return Configuration|mixed |
||
| 34 | */ |
||
| 35 | public function commandsPost($command = null) |
||
| 39 | } |
||
| 40 |
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.