Completed
Push — master ( 5289b1...66334b )
by Xu
06:18
created

QiniuAdapter   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
B init() 0 17 5
A displayName() 0 3 1
A prepareAdapter() 0 3 1
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
namespace yuncms\filesystem\adapters;
9
10
use Yii;
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
     * @inheritdoc
51
     */
52
    public static function displayName(): string
53
    {
54
        return Yii::t('yuncms', 'Qiniu');
55
    }
56
57
    /**
58
     * 准备适配器
59
     * @return \Overtrue\Flysystem\Qiniu\QiniuAdapter
60
     */
61
    protected function prepareAdapter()
62
    {
63
        return new \Overtrue\Flysystem\Qiniu\QiniuAdapter($this->accessId, $this->accessSecret, $this->bucket, $this->domain);
64
    }
65
}