DropboxFsComponent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 12 3
A initAdapter() 0 6 1
1
<?php
2
3
/**
4
 * This file is part of the 2amigos/yii2-flysystem-component project.
5
 *
6
 * (c) 2amigOS! <http://2amigos.us/>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace dosamigos\flysystem;
13
14
use Spatie\Dropbox\Client;
15
use Spatie\FlysystemDropbox\DropboxAdapter;
16
use yii\base\InvalidConfigException;
17
18
class DropboxFsComponent extends AbstractFsComponent
19
{
20
    /**
21
     * @var string
22
     */
23
    public $token;
24
25
    /**
26
     * @var string
27
     */
28
    public $prefix = '';
29
30
    /**
31
     * @inheritdoc
32
     */
33
    public function init()
34
    {
35
        if ($this->token === null) {
36
            throw new InvalidConfigException('The "token" property must be set.');
37
        }
38
39
        if (!is_string($this->prefix)) {
40
            throw new InvalidConfigException('The "prefix" property must be a string.');
41
        }
42
43
        parent::init();
44
    }
45
46
    /**
47
     * @return DropboxAdapter
48
     */
49
    protected function initAdapter()
50
    {
51
        return new DropboxAdapter(
52
            new Client($this->token), $this->prefix
53
        );
54
    }
55
}
56