Passed
Push — 6.0 ( 03c236...d3acc3 )
by yun
13:52
created

Local   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 4
Bugs 1 Features 0
Metric Value
eloc 15
c 4
b 1
f 0
dl 0
loc 32
ccs 9
cts 10
cp 0.9
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createAdapter() 0 13 2
A url() 0 6 2
1
<?php
2
// +----------------------------------------------------------------------
3
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
4
// +----------------------------------------------------------------------
5
// | Copyright (c) 2006~2021 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\filesystem\driver;
14
15
use League\Flysystem\AdapterInterface;
16
use League\Flysystem\Adapter\Local as LocalAdapter;
17
use think\filesystem\Driver;
18
19
class Local extends Driver
20
{
21
    /**
22
     * 配置参数
23
     * @var array
24
     */
25
    protected $config = [
26
        'root' => '',
27
    ];
28
29 6
    protected function createAdapter(): AdapterInterface
30
    {
31 6
        $permissions = $this->config['permissions'] ?? [];
32
33 6
        $links = ($this->config['links'] ?? null) === 'skip'
34
        ? LocalAdapter::SKIP_LINKS
35 6
        : LocalAdapter::DISALLOW_LINKS;
36
37 6
        return new LocalAdapter(
38 6
            $this->config['root'],
39 6
            LOCK_EX,
40 4
            $links,
41 4
            $permissions
42
        );
43
    }
44
45
    public function url(string $path): string
46
    {
47
        if (isset($this->config['url'])) {
48
            return $this->concatPathToUrl($this->config['url'], $path);
49
        }
50
        return parent::url($path);
51
    }
52
}
53