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

Local::url()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 6
ccs 0
cts 0
cp 0
crap 6
rs 10
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