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

UpyunAdapter::init()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

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