bytic /
filesystem
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Nip\Filesystem\FilesystemManager; |
||||
| 4 | |||||
| 5 | use Nip\Filesystem\FileDisk; |
||||
| 6 | |||||
| 7 | /** |
||||
| 8 | * Trait HasDisksTrait |
||||
| 9 | * @package Nip\Filesystem\FilesystemManager |
||||
| 10 | */ |
||||
| 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 | 1 | public function disk($name = null) |
|||
| 27 | { |
||||
| 28 | 1 | $name = $name ?: $this->getDefaultDriver(); |
|||
| 29 | |||||
| 30 | 1 | return $this->disks[$name] = $this->get($name); |
|||
| 31 | } |
||||
| 32 | |||||
| 33 | /** |
||||
| 34 | * Get the default driver name. |
||||
| 35 | * |
||||
| 36 | * @return string |
||||
| 37 | */ |
||||
| 38 | public function getDefaultDriver() |
||||
| 39 | { |
||||
| 40 | return config('filesystems.default'); |
||||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||||
| 41 | } |
||||
| 42 | |||||
| 43 | /** |
||||
| 44 | * Attempt to get the disk from the local cache. |
||||
| 45 | * |
||||
| 46 | * @param string $name |
||||
| 47 | * @return FileDisk |
||||
| 48 | */ |
||||
| 49 | 1 | protected function get($name) |
|||
| 50 | { |
||||
| 51 | 1 | return isset($this->disks[$name]) ? $this->disks[$name] : $this->resolve($name); |
|||
|
0 ignored issues
–
show
It seems like
resolve() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 52 | } |
||||
| 53 | } |
||||
| 54 |