Completed
Push — master ( 30d3de...6bbfea )
by Xu
29:18 queued 23:02
created

CosV4Adapter::prepareAdapter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * @link http://www.tintsoft.com/
4
 * @copyright Copyright (c) 2012 TintSoft Technology Co. Ltd.
5
 * @license http://www.tintsoft.com/license/
6
 */
7
8
9
namespace yuncms\filesystem\adapters;
10
11
12
use yii\base\InvalidConfigException;
13
use yuncms\filesystem\Adapter;
14
15
/**
16
 * Class CosV4Adapter
17
 *
18
 * @author Tongle Xu <[email protected]>
19
 * @since 3.0
20
 */
21
class CosV4Adapter extends Adapter
22
{
23
    public $protocol = 'http';
24
    public $appId;
25
    public $accessId;
26
    public $accessSecret;
27
    public $bucket;
28
    public $domain;
29
    public $region;
30
    public $timeout = 60;
31
    public $debug = false;
32
33
    /**
34
     * @inheritdoc
35
     */
36
    public function init()
37
    {
38
        if ($this->appId === null) {
39
            throw new InvalidConfigException('The "appId" property must be set.');
40
        }
41
        if ($this->accessId === null) {
42
            throw new InvalidConfigException('The "accessId" property must be set.');
43
        }
44
        if ($this->accessSecret === null) {
45
            throw new InvalidConfigException('The "accessSecret" property must be set.');
46
        }
47
        if ($this->bucket === null) {
48
            throw new InvalidConfigException('The "bucket" property must be set.');
49
        }
50
        if ($this->domain === null) {
51
            throw new InvalidConfigException('The "domain" property must be set.');
52
        }
53
        if ($this->region === null) {
54
            throw new InvalidConfigException('The "region" property must be set.');
55
        }
56
        parent::init();
57
    }
58
59
    /**
60
     * 准备适配器
61
     * @return \Freyo\Flysystem\QcloudCOSv4\Adapter
62
     */
63
    protected function prepareAdapter()
64
    {
65
        return new \Freyo\Flysystem\QcloudCOSv4\Adapter([
0 ignored issues
show
Bug introduced by
The call to Freyo\Flysystem\QcloudCOSv4\Adapter::__construct() has too few arguments starting with config. ( Ignorable by Annotation )

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

65
        return /** @scrutinizer ignore-call */ new \Freyo\Flysystem\QcloudCOSv4\Adapter([

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
66
            'protocol' => $this->protocol,
67
            'domain' => $this->domain,
68
            'app_id' => $this->appId,
69
            'secret_id' => $this->accessId,
70
            'secret_key' => $this->accessSecret,
71
            'timeout' => $this->timeout,
72
            'bucket' => $this->bucket,
73
            'region' => $this->region,
74
            'debug' => $this->debug,
75
        ]);
76
    }
77
}