DropboxFilesystem   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 32
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 7 2
A prepareAdapter() 0 6 1
1
<?php
2
/**
3
 * @link https://github.com/acidwave/yii2-flysystem
4
 * @copyright Copyright (c) 2021 Acid Wave
5
 * @license http://opensource.org/licenses/BSD-3-Clause
6
 */
7
8
namespace Acidwave\Flysystem;
9
10
use Spatie\Dropbox\Client;
11
use Spatie\FlysystemDropbox\DropboxAdapter;
12
use yii\base\InvalidConfigException;
13
14
/**
15
 * DropboxFilesystem
16
 *
17
 * @author Acid Wave <[email protected]>
18
 */
19
class DropboxFilesystem extends Filesystem
20
{
21
    /**
22
     * @var string
23
     */
24
    public $token;
25
    /**
26
     * @var string|null
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
        parent::init();
40
    }
41
42
    /**
43
     * @return DropboxAdapter
44
     */
45
    protected function prepareAdapter()
46
    {
47
        $this->config['case_sensitive'] = false;
48
        return new DropboxAdapter(
49
            new Client($this->token),
50
            $this->prefix
0 ignored issues
show
Bug introduced by
It seems like $this->prefix can also be of type null; however, parameter $prefix of Spatie\FlysystemDropbox\...xAdapter::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

50
            /** @scrutinizer ignore-type */ $this->prefix
Loading history...
51
        );
52
    }
53
}
54