| 1 | <?php |
||
| 11 | trait HasDisksTrait |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * The array of resolved filesystem drivers. |
||
| 15 | * |
||
| 16 | * @var FileDisk[] |
||
| 17 | */ |
||
| 18 | protected $disks = []; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Get a filesystem instance. |
||
| 22 | * |
||
| 23 | * @param string $name |
||
| 24 | * @return FileDisk |
||
| 25 | */ |
||
| 26 | public function disk($name = null) |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Get the default driver name. |
||
| 35 | * |
||
| 36 | * @return string |
||
| 37 | */ |
||
| 38 | public function getDefaultDriver() |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Attempt to get the disk from the local cache. |
||
| 45 | * |
||
| 46 | * @param string $name |
||
| 47 | * @return FileDisk |
||
| 48 | */ |
||
| 49 | protected function get($name) |
||
| 53 | } |
||
| 54 |
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.