Completed
Push — 6.0 ( c6d21a...a43f83 )
by yun
15:10 queued 11:06
created

Filesystem::disk()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 2
nop 1
dl 0
loc 11
ccs 6
cts 6
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
// +----------------------------------------------------------------------
3
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
4
// +----------------------------------------------------------------------
5
// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved.
6
// +----------------------------------------------------------------------
7
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
8
// +----------------------------------------------------------------------
9
// | Author: yunwuxin <[email protected]>
10
// +----------------------------------------------------------------------
11
declare (strict_types = 1);
12
13
namespace think;
14
15
use think\filesystem\Driver;
16
use think\filesystem\driver\Local;
17
18
/**
19
 * Class Filesystem
20
 * @package think
0 ignored issues
show
Coding Style introduced by
Package name "think" is not valid; consider "Think" instead
Loading history...
21
 * @mixin Driver
1 ignored issue
show
Coding Style introduced by
Tag value for @mixin tag indented incorrectly; expected 3 spaces but found 1
Loading history...
22
 * @mixin Local
1 ignored issue
show
Coding Style introduced by
Tag value for @mixin tag indented incorrectly; expected 3 spaces but found 1
Loading history...
23
 */
4 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
24
class Filesystem
25
{
26
    protected $disks;
27
28
    /** @var App */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
29
    protected $app;
30
31 3
    public function __construct($app)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
32
    {
33 3
        $this->app = $app;
34 3
    }
35
36
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
37
     * @param null|string $name
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
38
     * @return Driver
39
     */
40 3
    public function disk($name = null)
41
    {
42 3
        $name = $name ?: $this->app->config->get('filesystem.default');
43
44 3
        if (!isset($this->disks[$name])) {
45 3
            $config = $this->app->config->get("filesystem.disks.{$name}");
46
47 3
            $this->disks[$name] = App::factory($config['type'], '\\think\\filesystem\\driver\\', $config);
48
        }
49
50 3
        return $this->disks[$name];
51
    }
52
53 1
    public function __call($method, $parameters)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __call()
Loading history...
54
    {
55 1
        return $this->disk()->$method(...$parameters);
56
    }
57
}
58