BaseDriver::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
/**
3
 * @link https://github.com/phpviet/laravel-flysystem
4
 * @copyright (c) PHP Viet
5
 * @license [MIT](http://www.opensource.org/licenses/MIT)
6
 */
7
8
namespace PHPViet\Laravel\Flysystem\Drivers;
9
10
use League\Flysystem\FilesystemInterface;
11
use Illuminate\Contracts\Foundation\Application;
12
13
/**
14
 * @author Vuong Minh <[email protected]>
15
 * @since 1.0.0
16
 */
17
abstract class BaseDriver
18
{
19
    /**
20
     * @var Application
21
     */
22
    protected $app;
23
24
    /**
25
     * @var array
26
     */
27
    protected $config;
28
29
    /**
30
     * Khởi tạo đối tượng Filesystem thông qua callable.
31
     *
32
     * @param  \Illuminate\Contracts\Foundation\Application  $app
33
     * @param  array  $config
34
     * @return \League\Flysystem\FilesystemInterface
35
     */
36
    public function __invoke(Application $app, array $config): FilesystemInterface
37
    {
38
        $this->app = $app;
39
        $this->config = $config;
40
41
        return $this->createFilesystem();
42
    }
43
44
    /**
45
     * Phương thức trừu tượng tạo Filesystem theo config chỉ định.
46
     *
47
     * @return \League\Flysystem\FilesystemInterface
48
     */
49
    abstract protected function createFilesystem(): FilesystemInterface;
50
}
51