Passed
Pull Request — 6.0 (#2763)
by
unknown
11:24
created

Local::url()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 8
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\Local\LocalFilesystemAdapter;
16
use League\Flysystem\UnixVisibility\PortableVisibilityConverter;
17
use League\Flysystem\Visibility;
18
use think\filesystem\Driver;
19
20
class Local extends Driver
21
{
22
    /**
23
     * 配置参数
24
     * @var array
25
     */
26
    protected $config = [
27
        'root' => '',
28
    ];
29 6
30
    protected function createAdapter(): LocalFilesystemAdapter
31 6
    {
32
33 6
        $links = ($this->config['links'] ?? null) === 'skip'
34
        ? LocalFilesystemAdapter::SKIP_LINKS
35 6
        : LocalFilesystemAdapter::DISALLOW_LINKS;
36
37 6
        $visibility = PortableVisibilityConverter::fromArray(
38 6
            $config['permissions'] ?? [],
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $config seems to never exist and therefore isset should always be false.
Loading history...
39 6
            $config['directory_visibility'] ?? $config['visibility'] ?? Visibility::PRIVATE
40 4
        );
41 4
42
        return new LocalFilesystemAdapter(
43
            $this->config['root'],
44
            $visibility,
45
            $config['lock'] ?? LOCK_EX,
46
            $links
47
        );
48
    }
49
}
50