| 1 | <?php |
||
| 13 | trait HasFactories |
||
| 14 | { |
||
| 15 | /* ----------------------------------------------------------------- |
||
| 16 | | Main Methods |
||
| 17 | | ----------------------------------------------------------------- |
||
| 18 | */ |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Get the migrations path. |
||
| 22 | * |
||
| 23 | * @return string |
||
| 24 | */ |
||
| 25 | protected function getFactoriesPath(): string |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Publish the factories. |
||
| 32 | * |
||
| 33 | * @param string|null $path |
||
| 34 | */ |
||
| 35 | protected function publishFactories(?string $path = null): void |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Load the factories. |
||
| 44 | */ |
||
| 45 | protected function loadFactories(): void |
||
| 49 | } |
||
| 50 |
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.