Completed
Push — master ( bfc0cc...f0e226 )
by sabaku
04:05
created

Config   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 116
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 116
rs 10
c 1
b 1
f 0
wmc 6
lcom 1
cbo 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A setOperatorPassword() 0 3 1
A getFormApiKey() 0 7 2
A setFormApiKey() 0 3 1
A getVersion() 0 3 1
1
<?php
2
namespace Upyun;
3
4
/**
5
 * Class Config
6
 *
7
 * @package Upyun
8
 */
9
class Config {
10
    /**
11
     * @var string 服务名称
12
     */
13
    public $bucketName;
14
    /**
15
     * @var string 操作员名
16
     */
17
    public $operatorName;
18
    /**
19
     * @var string 操作员密码 md5 hash 值
20
     */
21
    public $operatorPassword;
22
23
    /**
24
     * @var bool 是否使用 https
25
     */
26
    public $useSsl;
27
28
    /**
29
     * @var string 上传使用的接口类型,可以设置为 `REST`:使用 rest api 上传,`AUTO` 根据文件大小自动判断,`BLOCK` 使用断点续传
30
     * 当上传小文件时,不推荐使用断点续传;上传时如果设置了异步预处理`withAsyncProcess=true`,将会使用表单 api 上传
31
     */
32
    public $uploadType = 'AUTO';
33
34
    /**
35
     * @var int 上传的接口类型设置为 `AUTO` 时,文件大小的边界值:小于该值时,使用 rest api,否则使用断点续传。 默认 30M
36
     */
37
    public $sizeBoundary = 31457280;
38
    /**
39
     * @var int 分块上传`Multi`接口的最大分块值
40
     */
41
    public $maxBlockSize = 5242880;
42
43
    /**
44
     * @var int 分块时,每个块的过期时间
45
     */
46
    public $blockExpiration = 60;
47
48
    /**
49
     * @var int request timeout seconds
50
     */
51
    public $timeout = 60;
52
53
54
    /**
55
     * @var string 异步云处理的回调通知地址
56
     */
57
    public $processNotifyUrl;
58
59
    private $version = '3.0.0';
60
61
62
63
    /**
64
     * @var string 表单 api 的秘钥
65
     */
66
    private $formApiKey;
67
68
    /**
69
     * @var string rest api 和 form api 的接口地址
70
     */
71
    static $restApiEndPoint;
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $restApiEndPoint.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
72
73
74
    /**
75
     * rest api 和 form api 接口请求地址,详见:http://docs.upyun.com/api/rest_api/
76
     */
77
    const ED_AUTO            = 'v0.api.upyun.com';
78
    const ED_TELECOM         = 'v1.api.upyun.com';
79
    const ED_CNC             = 'v2.api.upyun.com';
80
    const ED_CTT             = 'v3.api.upyun.com';
81
82
    /**
83
     * 分块上传接口请求地址
84
     */
85
    const ED_FORM            = 'm0.api.upyun.com';
86
87
    /**
88
     * 异步云处理接口地址
89
     */
90
    const ED_VIDEO           = 'p0.api.upyun.com';
91
92
    /**
93
     * 刷新接口地址
94
     */
95
    const ED_PURGE           = 'http://purge.upyun.com/purge/';
96
97
    public function __construct($bucketName, $operatorName, $operatorPassword) {
98
        $this->bucketName = $bucketName;
99
        $this->operatorName = $operatorName;
100
        $this->setOperatorPassword($operatorPassword);
101
        $this->useSsl          = false;
102
        self::$restApiEndPoint = self::ED_AUTO;
103
    }
104
105
    public function setOperatorPassword($operatorPassword) {
106
        $this->operatorPassword = md5($operatorPassword);
107
    }
108
109
    public function getFormApiKey() {
110
        if(! $this->formApiKey) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
111
            throw new \Exception('form api key is empty.');
112
        }
113
114
       return $this->formApiKey;
115
    }
116
117
    public function setFormApiKey($key) {
118
        $this->formApiKey = $key;
119
    }
120
121
    public function getVersion() {
122
        return $this->version;
123
    }
124
}
125