Passed
Pull Request — master (#60)
by
unknown
13:05
created
tests/bootstrap.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2
-require dirname(__DIR__) . '/vendor/autoload.php';
2
+require dirname(__DIR__).'/vendor/autoload.php';
3 3
 
4 4
 define('USER_NAME', 'tester');
5 5
 define('PWD', 'grjxv2mxELR3');
6 6
 define('BUCKET', 'sdkimg');
7
-define('PIC_PATH', dirname(__FILE__) . '/assets/sample.jpeg');
7
+define('PIC_PATH', dirname(__FILE__).'/assets/sample.jpeg');
8 8
 define('PIC_SIZE', filesize(PIC_PATH));
9 9
 
10 10
 function getFileUrl($path)
11 11
 {
12
-    return "http://" . BUCKET . ".b0.upaiyun.com/" . ltrim($path, '/');
12
+    return "http://".BUCKET.".b0.upaiyun.com/".ltrim($path, '/');
13 13
 }
14 14
 
15 15
 function getUpyunFileSize($path)
Please login to merge, or discard this patch.
src/Upyun/Util.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,12 +72,12 @@
 block discarded – undo
72 72
     public static function encodeURI($url)
73 73
     {
74 74
         $unescaped = array(
75
-            '%2D'=>'-','%5F'=>'_','%2E'=>'.','%21'=>'!', '%7E'=>'~',
75
+            '%2D'=>'-', '%5F'=>'_', '%2E'=>'.', '%21'=>'!', '%7E'=>'~',
76 76
             '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')'
77 77
         );
78 78
         $reserved = array(
79
-            '%3B'=>';','%2C'=>',','%2F'=>'/','%3F'=>'?','%3A'=>':',
80
-            '%40'=>'@','%26'=>'&','%3D'=>'=','%2B'=>'+','%24'=>'$'
79
+            '%3B'=>';', '%2C'=>',', '%2F'=>'/', '%3F'=>'?', '%3A'=>':',
80
+            '%40'=>'@', '%26'=>'&', '%3D'=>'=', '%2B'=>'+', '%24'=>'$'
81 81
         );
82 82
         $score = array(
83 83
             '%23'=>'#'
Please login to merge, or discard this patch.
src/Upyun/Api/Form.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 
19 19
         $policy = Util::base64Json($params);
20 20
         $method = 'POST';
21
-        $signature = Signature::getBodySignature($this->config, $method, '/' . $params['service'], null, $policy);
21
+        $signature = Signature::getBodySignature($this->config, $method, '/'.$params['service'], null, $policy);
22 22
         $client = new Client([
23 23
             'timeout' => $this->config->timeout,
24 24
         ]);
Please login to merge, or discard this patch.
src/Upyun/Api/Pretreat.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $method = 'POST';
44 44
         $signedHeaders = Signature::getHeaderSign($this->config, $method, $path);
45 45
 
46
-        $url = $this->config->getPretreatEndPoint() . $path;
46
+        $url = $this->config->getPretreatEndPoint().$path;
47 47
         $response = $client->request($method, $url, [
48 48
             'headers' => $signedHeaders,
49 49
             'form_params' => $params
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
             'service' => $this->config->serviceName,
65 65
             'task_ids' => implode(',', $taskIds)
66 66
         );
67
-        $path = $path . '?' . http_build_query($params);
67
+        $path = $path.'?'.http_build_query($params);
68 68
 
69 69
         $method = 'GET';
70
-        $url = $this->config->getPretreatEndPoint() . $path;
70
+        $url = $this->config->getPretreatEndPoint().$path;
71 71
         $signedHeaders = Signature::getHeaderSign($this->config, $method, $path);
72 72
         $response = $client->request($method, $url, [
73 73
             'headers' => $signedHeaders
Please login to merge, or discard this patch.
src/Upyun/Signature.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@  discard block
 block discarded – undo
10 10
     /**
11 11
      * 获取分块上传接口的签名
12 12
      */
13
-    const SIGN_MULTIPART     = 1;
13
+    const SIGN_MULTIPART = 1;
14 14
     /**
15 15
      * 生成视频处理接口的签名
16 16
      */
17
-    const SIGN_VIDEO         = 2;
17
+    const SIGN_VIDEO = 2;
18 18
     /**
19 19
      * 生成视频处理接口的签名(不需要操作员时使用)
20 20
      */
21
-    const SIGN_VIDEO_NO_OPERATOR   = 3;
21
+    const SIGN_VIDEO_NO_OPERATOR = 3;
22 22
 
23 23
     /**
24 24
      * 获取 Header 签名需要的请求头
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         $headers = array(
41 41
             'Authorization' => $sign,
42 42
             'Date' => $gmtDate,
43
-            'User-agent' => 'Php-Sdk/' . $serviceConfig->getVersion()
43
+            'User-agent' => 'Php-Sdk/'.$serviceConfig->getVersion()
44 44
         );
45 45
         return $headers;
46 46
     }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         return array(
61 61
             'Authorization' => "UpYun {$serviceConfig->serviceName}:{$serviceConfig->operatorName}:$sign",
62 62
             'Date' => $gmtDate,
63
-            'User-agent' => 'Php-Sdk/' . $serviceConfig->getVersion() . ' (purge api)'
63
+            'User-agent' => 'Php-Sdk/'.$serviceConfig->getVersion().' (purge api)'
64 64
         );
65 65
     }
66 66
 
@@ -93,6 +93,6 @@  discard block
 block discarded – undo
93 93
             $data[] = $contentMd5;
94 94
         }
95 95
         $signature = base64_encode(hash_hmac('sha1', implode('&', $data), $serviceConfig->operatorPassword, true));
96
-        return 'UPYUN ' . $serviceConfig->operatorName . ':' . $signature;
96
+        return 'UPYUN '.$serviceConfig->operatorName.':'.$signature;
97 97
     }
98 98
 }
Please login to merge, or discard this patch.
src/Upyun/Upyun.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,6 @@
 block discarded – undo
5 5
 namespace Upyun;
6 6
 
7 7
 use Upyun\Api\Rest;
8
-
9 8
 use GuzzleHttp\Client;
10 9
 use GuzzleHttp\Psr7;
11 10
 use GuzzleHttp;
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
         $params = Util::getHeaderParams($response->getHeaders());
153 153
 
154 154
 
155
-        if (! isset($params['x-upyun-list-iter'])) {
155
+        if (!isset($params['x-upyun-list-iter'])) {
156 156
             if (is_resource($saveHandler)) {
157 157
                 Psr7\copy_to_stream($response->getBody(), Psr7\stream_for($saveHandler));
158 158
                 return true;
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
      */
257 257
     public function createDir($path)
258 258
     {
259
-        $path = rtrim($path, '/') . '/';
259
+        $path = rtrim($path, '/').'/';
260 260
         $req = new Rest($this->config);
261 261
         $res = $req->request('POST', $path)
262 262
             ->withHeader('folder', 'true')
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
      */
287 287
     public function usage($path = '/')
288 288
     {
289
-        $path = rtrim($path, '/') . '/';
289
+        $path = rtrim($path, '/').'/';
290 290
         $req = new Rest($this->config);
291
-        $response = $req->request('GET', $path . '?usage')
291
+        $response = $req->request('GET', $path.'?usage')
292 292
             ->send();
293 293
 
294 294
         return $response->getBody()->getContents();
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
      */
305 305
     public function copy($source, $target)
306 306
     {
307
-        $source = '/' . $this->config->serviceName . '/' . ltrim($source, '/');
307
+        $source = '/'.$this->config->serviceName.'/'.ltrim($source, '/');
308 308
         $req = new Rest($this->config);
309 309
         $response = $req->request('PUT', $target)
310 310
             ->withHeader('X-Upyun-Copy-Source', $source)
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
      */
323 323
     public function move($source, $target)
324 324
     {
325
-        $source = '/' . $this->config->serviceName . '/' . ltrim($source, '/');
325
+        $source = '/'.$this->config->serviceName.'/'.ltrim($source, '/');
326 326
         $req = new Rest($this->config);
327 327
         $response = $req->request('PUT', $target)
328 328
             ->withHeader('X-Upyun-Move-Source', $source)
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
         $video = new Api\Pretreat($this->config);
400 400
 
401 401
         $options = array();
402
-        switch($type) {
402
+        switch ($type) {
403 403
             case self::$PROCESS_TYPE_MEDIA:
404 404
                 $options['accept'] = 'json';
405 405
                 $options['source'] = $source;
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      * 获取云存储文件/目录的基本信息
198 198
      *
199 199
      * @param string $path 云存储的文件路径
200
-     * @param array $otherHeaders 设置了后,方法将返回其他 http header 中的信息,默认为空
200
+     * @param string[] $otherHeaders 设置了后,方法将返回其他 http header 中的信息,默认为空
201 201
      *
202 202
      * @return array 返回一个数组,默认包含以下 key
203 203
      * - `x-upyun-file-type` 当 $path 是目录时,值为 *folder*,当 $path 是文件时,值为 *file*,
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
     /**
334 334
      * 刷新缓存
335 335
      *
336
-     * @param array|string $urls 需要刷新的文件 url 列表
336
+     * @param string $urls 需要刷新的文件 url 列表
337 337
      *
338 338
      * @return array 刷新失败的 url 列表,若全部刷新成功则为空数组
339 339
      */
Please login to merge, or discard this patch.
src/Upyun/Api/SyncVideo.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@
 block discarded – undo
26 26
             'timeout' => $this->config->timeout,
27 27
         ]);
28 28
 
29
-        $path = '/' . $this->config->serviceName . $path;
29
+        $path = '/'.$this->config->serviceName.$path;
30 30
         $method = 'POST';
31 31
         $signedHeaders = Signature::getHeaderSign($this->config, $method, $path);
32 32
 
33
-        $url = $this->config->getSyncVideoEndPoint() . $path;
33
+        $url = $this->config->getSyncVideoEndPoint().$path;
34 34
         $response = $client->request($method, $url, [
35 35
             'headers' => $signedHeaders,
36 36
             'json' => $params
Please login to merge, or discard this patch.
src/Upyun/Config.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -84,17 +84,17 @@  discard block
 block discarded – undo
84 84
     /**
85 85
      * 异步云处理接口地址
86 86
      */
87
-    const ED_VIDEO           = 'p0.api.upyun.com';
87
+    const ED_VIDEO = 'p0.api.upyun.com';
88 88
 
89 89
     /**
90 90
      * 刷新接口地址
91 91
      */
92
-    const ED_PURGE           = 'http://purge.upyun.com/purge/';
92
+    const ED_PURGE = 'http://purge.upyun.com/purge/';
93 93
 
94 94
     /**
95 95
      * 同步视频处理接口地址
96 96
      */
97
-    const ED_SYNC_VIDEO           = 'p1.api.upyun.com';
97
+    const ED_SYNC_VIDEO = 'p1.api.upyun.com';
98 98
 
99 99
     public function __construct($serviceName, $operatorName, $operatorPassword)
100 100
     {
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
     public function getFormApiKey()
115 115
     {
116
-        if (! $this->formApiKey) {
116
+        if (!$this->formApiKey) {
117 117
             throw new \Exception('form api key is empty.');
118 118
         }
119 119
 
@@ -132,12 +132,12 @@  discard block
 block discarded – undo
132 132
 
133 133
     public function getPretreatEndPoint()
134 134
     {
135
-        return $this->getProtocol() . self::ED_VIDEO;
135
+        return $this->getProtocol().self::ED_VIDEO;
136 136
     }
137 137
 
138 138
     public function getSyncVideoEndPoint()
139 139
     {
140
-        return $this->getProtocol() . self::ED_SYNC_VIDEO;
140
+        return $this->getProtocol().self::ED_SYNC_VIDEO;
141 141
     }
142 142
 
143 143
     public function getProtocol()
Please login to merge, or discard this patch.
src/Upyun/Api/Rest.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
     public function __construct(Config $config)
30 30
     {
31 31
         $this->config   = $config;
32
-        $this->endpoint = $config->getProtocol() . Config::$restApiEndPoint . '/' . $config->serviceName;
32
+        $this->endpoint = $config->getProtocol().Config::$restApiEndPoint.'/'.$config->serviceName;
33 33
     }
34 34
 
35 35
     public function request($method, $storagePath)
36 36
     {
37 37
         $this->method = strtoupper($method);
38
-        $this->storagePath = '/' . ltrim($storagePath, '/');
38
+        $this->storagePath = '/'.ltrim($storagePath, '/');
39 39
         return $this;
40 40
     }
41 41
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             'timeout' => $this->config->timeout,
63 63
         ]);
64 64
 
65
-        $url = $this->endpoint . $this->storagePath;
65
+        $url = $this->endpoint.$this->storagePath;
66 66
         $body = null;
67 67
         if ($this->file && $this->method === 'PUT') {
68 68
             $body = $this->file;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
     public function toRequest()
110 110
     {
111
-        $url = $this->endpoint . $this->storagePath;
111
+        $url = $this->endpoint.$this->storagePath;
112 112
         $body = null;
113 113
         if ($this->file && $this->method === 'PUT') {
114 114
             $body = $this->file;
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,6 +32,9 @@  discard block
 block discarded – undo
32 32
         $this->endpoint = $config->getProtocol() . Config::$restApiEndPoint . '/' . $config->serviceName;
33 33
     }
34 34
 
35
+    /**
36
+     * @param string $method
37
+     */
35 38
     public function request($method, $storagePath)
36 39
     {
37 40
         $this->method = strtoupper($method);
@@ -41,7 +44,7 @@  discard block
 block discarded – undo
41 44
 
42 45
 
43 46
     /**
44
-     * @param string|resource $file
47
+     * @param \Psr\Http\Message\StreamInterface $file
45 48
      *
46 49
      * @return $this
47 50
      */
@@ -54,7 +57,7 @@  discard block
 block discarded – undo
54 57
     }
55 58
 
56 59
     /**
57
-     * @return mixed|\Psr\Http\Message\ResponseInterface
60
+     * @return \Psr\Http\Message\ResponseInterface
58 61
      */
59 62
     public function send()
60 63
     {
Please login to merge, or discard this patch.