| 1 | <?php |
||
| 13 | trait HasAssets |
||
| 14 | { |
||
| 15 | /* ----------------------------------------------------------------- |
||
| 16 | | Getters & Setters |
||
| 17 | | ----------------------------------------------------------------- |
||
| 18 | */ |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Get the assets path. |
||
| 22 | * |
||
| 23 | * @return string |
||
| 24 | */ |
||
| 25 | protected function getAssetsFolder(): string |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Get the assets destination path. |
||
| 32 | * |
||
| 33 | * @return string |
||
| 34 | */ |
||
| 35 | protected function assetsDestinationPath(): string |
||
| 39 | |||
| 40 | /* ----------------------------------------------------------------- |
||
| 41 | | Getters & Setters |
||
| 42 | | ----------------------------------------------------------------- |
||
| 43 | */ |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Publish the assets. |
||
| 47 | */ |
||
| 48 | protected function publishAssets(): void |
||
| 54 | } |
||
| 55 |
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.