WebDAVFsComponent   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 62
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 8 2
A initAdapter() 0 15 1
1
<?php
2
/**
3
 * This file is part of the 2amigos/yii2-flysystem-component project.
4
 *
5
 * (c) 2amigOS! <http://2amigos.us/>
6
 *
7
 * For the full copyright and license information, please view
8
 * the LICENSE file that was distributed with this source code.
9
 */
10
namespace dosamigos\flysystem;
11
12
use League\Flysystem\WebDAV\WebDAVAdapter;
13
use Sabre\DAV\Client;
14
use yii\base\InvalidConfigException;
15
16
class WebDAVFsComponent extends AbstractFsComponent
17
{
18
    /**
19
     * @var string
20
     */
21
    public $baseUri;
22
    /**
23
     * @var string
24
     */
25
    public $userName;
26
    /**
27
     * @var string
28
     */
29
    public $password;
30
    /**
31
     * @var string
32
     */
33
    public $proxy;
34
    /**
35
     * @var integer
36
     */
37
    public $authType;
38
    /**
39
     * @var integer
40
     */
41
    public $encoding;
42
    /**
43
     * @var string|null
44
     */
45
    public $prefix;
46
47
    /**
48
     * @inheritdoc
49
     */
50
    public function init()
51
    {
52
        if ($this->baseUri === null) {
53
            throw new InvalidConfigException('The "baseUri" property must be set.');
54
        }
55
56
        parent::init();
57
    }
58
59
    /**
60
     * @return WebDAVAdapter
61
     */
62
    protected function initAdapter()
63
    {
64
        $config = array_filter(
65
            [
66
                'baseUri' => $this->baseUri,
67
                'userName' => $this->userName,
68
                'password' => $this->password,
69
                'proxy' => $this->proxy,
70
                'authType' => $this->authType,
71
                'encoding' => $this->encoding,
72
            ]
73
        );
74
75
        return new WebDAVAdapter(new Client($config), $this->prefix);
76
    }
77
}
78