Completed
Push — master ( f0e226...e1b15c )
by sabaku
04:13
created
src/Upyun/Upyun.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      * @throws \Exception 上传失败时,抛出异常
87 87
      */
88 88
     public function write($path, $content, $params = array(), $withAsyncProcess = false) {
89
-        if(!$content) {
89
+        if (!$content) {
90 90
             throw new \Exception('write content can not be empty.');
91 91
         }
92 92
 
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
         $params = Util::getHeaderParams($response->getHeaders());
123 123
 
124 124
 
125
-        if(! isset($params['x-upyun-list-iter'])) {
126
-            if(is_resource($saveHandler)) {
125
+        if (!isset($params['x-upyun-list-iter'])) {
126
+            if (is_resource($saveHandler)) {
127 127
                 Psr7\copy_to_stream($response->getBody(), Psr7\stream_for($saveHandler));
128 128
                 return true;
129 129
             } else {
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
         try {
151 151
             $req->request('HEAD', $path)
152 152
                             ->send();
153
-        } catch(GuzzleHttp\Exception\BadResponseException $e) {
153
+        } catch (GuzzleHttp\Exception\BadResponseException $e) {
154 154
             $statusCode = $e->getResponse()->getStatusCode();
155
-            if($statusCode === 404) {
155
+            if ($statusCode === 404) {
156 156
                 return false;
157 157
             } else {
158 158
                 throw $e;
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     public function delete($path, $async = false) {
192 192
         $req = new Rest($this->config);
193 193
         $req->request('DELETE', $path);
194
-        if($async) {
194
+        if ($async) {
195 195
             $req->withHeader('x-upyun-async', 'true');
196 196
         }
197 197
         $res = $req->send();
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
      * @throws \Exception
208 208
      */
209 209
     public function createDir($path) {
210
-        $path = rtrim($path, '/') . '/';
210
+        $path = rtrim($path, '/').'/';
211 211
         $req = new Rest($this->config);
212 212
         $res = $req->request('POST', $path)
213 213
             ->withHeader('folder', 'true')
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
      */
237 237
     public function usage($path = '/') {
238 238
 
239
-        $path = rtrim($path, '/') . '/';
239
+        $path = rtrim($path, '/').'/';
240 240
         $req = new Rest($this->config);
241
-        $response = $req->request('GET', $path . '?usage')
241
+        $response = $req->request('GET', $path.'?usage')
242 242
             ->withHeader('folder', 'true')
243 243
             ->send();
244 244
 
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
      */
255 255
     public function purge($urls) {
256 256
         $urlString = $urls;
257
-        if(is_array($urls)) {
257
+        if (is_array($urls)) {
258 258
             $urlString = implode("\n", $urls);
259 259
         }
260 260
 
Please login to merge, or discard this patch.
src/Upyun/Video.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@
 block discarded – undo
87 87
         $callbackParams = array();
88 88
         foreach($callbackKeys as $key) {
89 89
             if(isset($_POST[$key])) {
90
-               $callbackParams[$key] = Util::trim($_POST[$key]);
90
+                $callbackParams[$key] = Util::trim($_POST[$key]);
91 91
             }
92 92
         }
93 93
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
             $postParams
33 33
         );
34 34
 
35
-        if($response->status_code !== 200) {
35
+        if ($response->status_code !== 200) {
36 36
             $body = json_decode($response->body, true);
37 37
             throw new \Exception(sprintf('%s, with x-request-id=%s', $body['msg'], $body['id']), $body['code']);
38 38
         }
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         if (count($taskIds) <= $limit) {
49 49
             $taskIds = implode(',', $taskIds);
50 50
         } else {
51
-            throw new \Exception('can not query more than ' . $limit . ' tasks at one time!');
51
+            throw new \Exception('can not query more than '.$limit.' tasks at one time!');
52 52
         }
53 53
 
54 54
         $query['task_ids'] = $taskIds;
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
             $query
66 66
         );
67 67
 
68
-        if($response->status_code !== 200) {
68
+        if ($response->status_code !== 200) {
69 69
             $body = json_decode($response->body, true);
70 70
             throw new \Exception(sprintf('%s, with x-request-id=%s', $body['msg'], $body['id']), $body['code']);
71 71
         }
Please login to merge, or discard this patch.
src/Upyun/Api/Form.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use Upyun\Signature;
6 6
 use GuzzleHttp\Client;
7 7
 
8
-class Form extends Rest{
8
+class Form extends Rest {
9 9
 
10 10
     public function upload($path, $stream, $params) {
11 11
         $params['save-key'] = $path;
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
             'timeout' => $this->config->timeout,
22 22
         ]);
23 23
 
24
-        $url = ($this->config->useSsl ? 'https://' : 'http://') . $this->endpoint;
24
+        $url = ($this->config->useSsl ? 'https://' : 'http://').$this->endpoint;
25 25
 
26 26
         $response = $client->request('POST', $url, array(
27 27
             'multipart' => array(
Please login to merge, or discard this patch.
src/Upyun/Util.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 class Util {
4 4
 
5 5
     public static function trim($str) {
6
-        if(is_array($str)) {
6
+        if (is_array($str)) {
7 7
             return array_map(array('Util', 'trim'), $str);
8 8
         } else {
9 9
             return trim($str);
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
         $params = [];
15 15
         foreach ($headers as $header => $value) {
16 16
             $header = strtolower($header);
17
-            if(strpos($header, 'x-upyun-') !== false) {
17
+            if (strpos($header, 'x-upyun-') !== false) {
18 18
                 $params[$header] = $value[0];
19 19
             }
20 20
         }
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
     
24 24
     public static function parseDir($body) {
25 25
         $files = array();
26
-        if(!$body) {
26
+        if (!$body) {
27 27
             return array('files' => $files, 'is_end' => true);
28 28
         }
29 29
 
30 30
         $lines = explode("\n", $body);
31
-        foreach($lines as $line) {
31
+        foreach ($lines as $line) {
32 32
             $file = [];
33 33
             list($file['name'], $file['type'], $file['size'], $file['time']) = explode("\t", $line, 4);
34 34
             $files[] = $file;
Please login to merge, or discard this patch.
src/Upyun/Signature.php 1 patch
Spacing   +9 added lines, -9 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
      * 获取 RESET API 请求需要的签名头
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public static function getRestApiSignHeader($bucketConfig, $method, $remotePath, $contentLength) {
34 34
         $gmtDate = gmdate('D, d M Y H:i:s \G\M\T');
35
-        $path = '/' . $bucketConfig->bucketName . '/' . ltrim($remotePath, '/');
35
+        $path = '/'.$bucketConfig->bucketName.'/'.ltrim($remotePath, '/');
36 36
 
37 37
         $sign = md5("$method&$path&$gmtDate&$contentLength&{$bucketConfig->operatorPassword}");
38 38
 
39 39
         $headers = array(
40 40
             'Authorization' => "UpYun {$bucketConfig->operatorName}:$sign",
41 41
             'Date' => $gmtDate,
42
-            'User-agent' => 'Php-Sdk/' . $bucketConfig->getVersion() . ' (rest api)'
42
+            'User-agent' => 'Php-Sdk/'.$bucketConfig->getVersion().' (rest api)'
43 43
         );
44 44
         return $headers;
45 45
     }
@@ -58,21 +58,21 @@  discard block
 block discarded – undo
58 58
         return array(
59 59
             'Authorization' => "UpYun {$bucketConfig->bucketName}:{$bucketConfig->operatorName}:$sign",
60 60
             'Date' => $gmtDate,
61
-            'User-agent' => 'Php-Sdk/' . $bucketConfig->getVersion() . ' (purge api)'
61
+            'User-agent' => 'Php-Sdk/'.$bucketConfig->getVersion().' (purge api)'
62 62
         );
63 63
     }
64 64
 
65 65
     public static function getFormSignature(Config $bucketConfig, $data) {
66 66
         $data['bucket'] = $bucketConfig->bucketName;
67 67
         $policy = Util::base64Json($data);
68
-        $signature = md5($policy . '&' . $bucketConfig->getFormApiKey());
68
+        $signature = md5($policy.'&'.$bucketConfig->getFormApiKey());
69 69
         return array(
70 70
             'policy' => $policy,
71 71
             'signature' => $signature
72 72
         );
73 73
     }
74 74
 
75
-    public static function getSignature( Config $bucketConfig, $data, $type, $tokenSecret = '') {
75
+    public static function getSignature(Config $bucketConfig, $data, $type, $tokenSecret = '') {
76 76
         if (is_array($data)) {
77 77
             ksort($data);
78 78
             $string = '';
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
                     $string .= $tokenSecret ? $tokenSecret : $bucketConfig->getFormApiKey();
88 88
                     break;
89 89
                 case self::SIGN_VIDEO:
90
-                    $string = $bucketConfig->operatorName . $string . $bucketConfig->operatorPassword;
90
+                    $string = $bucketConfig->operatorName.$string.$bucketConfig->operatorPassword;
91 91
                     break;
92 92
                 case self::SIGN_VIDEO_NO_OPERATOR:
93 93
                     break;
Please login to merge, or discard this patch.