-
Notifications
You must be signed in to change notification settings - Fork 4
/
Storage.php
51 lines (41 loc) · 1.03 KB
/
Storage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace Core;
use InvalidArgumentException;
use Core\File\AwsS3Adapter;
use Core\File\LocalAdapter;
/**
* Storage class.
*
* @author Nguyen The Manh <nguyenthemanh26011996@gmail.com>
*/
class Storage
{
public function getConfig($key = '')
{
if ($key) {
return Config::get("filesystems.{$key}");
}
return Config::get('filesystems');
}
public function getCurrentDisk()
{
return $this->getConfig('default');
}
public function disk($name = '')
{
$name = $name ?: $this->getConfig("default");
if (! in_array( $name, array_keys( $this->getConfig('disks') ) ) ) {
throw new InvalidArgumentException(sprintf("Disk %s do not support", $name));
}
switch ($name) {
case 's3':
return new AwsS3Adapter;
default:
return new LocalAdapter;
}
}
public function __call($method, $arguments)
{
return $this->disk()->$method(...$arguments);
}
}