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

QiniuAdapter::prepareAdapter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
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
use yii\base\InvalidConfigException;
12
use yuncms\filesystem\Adapter;
13
14
/**
15
 * Class QiniuAdapter
16
 *
17
 * @author Tongle Xu <[email protected]>
18
 * @since 3.0
19
 */
20
class QiniuAdapter extends Adapter
21
{
22
    public $accessId;
23
    public $accessSecret;
24
    public $bucket;
25
    public $domain;
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function init()
31
    {
32
        if ($this->accessId === null) {
33
            throw new InvalidConfigException('The "accessId" property must be set.');
34
        }
35
36
        if ($this->accessSecret === null) {
37
            throw new InvalidConfigException('The "accessSecret" property must be set.');
38
        }
39
40
        if ($this->bucket === null) {
41
            throw new InvalidConfigException('The "bucket" property must be set.');
42
        }
43
        if ($this->domain === null) {
44
            throw new InvalidConfigException('The "domain" property must be set.');
45
        }
46
        parent::init();
47
    }
48
49
    /**
50
     * 准备适配器
51
     * @return \Overtrue\Flysystem\Qiniu\QiniuAdapter
52
     */
53
    protected function prepareAdapter()
54
    {
55
        return new \Overtrue\Flysystem\Qiniu\QiniuAdapter($this->accessId, $this->accessSecret, $this->bucket, $this->domain);
56
    }
57
}