Passed
Push — v6 ( 27c58a...fe399c )
by 光春
03:53
created
src/service/ksyun/bin/Ks3Client.class.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
 define("KS3_API_Author", "[email protected]");
35 35
 define("KS3_API_Version", "1.2");
36 36
 
37
-require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "Consts.php";
38
-require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "API.php";
39
-require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "Signers.php";
40
-require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "Ks3Request.class.php";
41
-require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "Handlers.php";
42
-require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "Builders.php";
43
-require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "Logger.php";
44
-require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "core" . DIRECTORY_SEPARATOR . "MessageHolder.php";
45
-require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "RequestCore.class.php";
46
-require_once KS3_API_PATH . DIRECTORY_SEPARATOR . "exceptions" . DIRECTORY_SEPARATOR . "Exceptions.php";
37
+require_once KS3_API_PATH.DIRECTORY_SEPARATOR."config".DIRECTORY_SEPARATOR."Consts.php";
38
+require_once KS3_API_PATH.DIRECTORY_SEPARATOR."core".DIRECTORY_SEPARATOR."API.php";
39
+require_once KS3_API_PATH.DIRECTORY_SEPARATOR."core".DIRECTORY_SEPARATOR."Signers.php";
40
+require_once KS3_API_PATH.DIRECTORY_SEPARATOR."core".DIRECTORY_SEPARATOR."Ks3Request.class.php";
41
+require_once KS3_API_PATH.DIRECTORY_SEPARATOR."core".DIRECTORY_SEPARATOR."Handlers.php";
42
+require_once KS3_API_PATH.DIRECTORY_SEPARATOR."core".DIRECTORY_SEPARATOR."Builders.php";
43
+require_once KS3_API_PATH.DIRECTORY_SEPARATOR."core".DIRECTORY_SEPARATOR."Logger.php";
44
+require_once KS3_API_PATH.DIRECTORY_SEPARATOR."core".DIRECTORY_SEPARATOR."MessageHolder.php";
45
+require_once KS3_API_PATH.DIRECTORY_SEPARATOR."lib".DIRECTORY_SEPARATOR."RequestCore.class.php";
46
+require_once KS3_API_PATH.DIRECTORY_SEPARATOR."exceptions".DIRECTORY_SEPARATOR."Exceptions.php";
47 47
 
48 48
 if (function_exists('get_loaded_extensions')) {
49 49
     //检测curl扩展
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
             throw new Ks3ClientException("please install mbstring extension");
57 57
 
58 58
         }
59
-    } else {
59
+    }else {
60 60
         throw new Ks3ClientException("please install extensions");
61 61
     }
62
-} else {
62
+}else {
63 63
     throw new Ks3ClientException();
64 64
 }
65 65
 
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
         $holder = new MessageHolder();
127 127
 
128 128
         $holder->msg = "------------------Logging Start-------------------------\r\n";
129
-        $holder->msg .= "method->" . $method . " args->" . serialize($args) . "\r\n";
129
+        $holder->msg .= "method->".$method." args->".serialize($args)."\r\n";
130 130
         $ex = NULL;
131 131
         try {
132 132
             $result = $this->invoke($method, $args, $holder);
133 133
         } catch (Exception $e) {
134
-            $holder->msg .= $e . "\r\n";
134
+            $holder->msg .= $e."\r\n";
135 135
             $ex = $e;
136 136
         }
137 137
         $holder->msg .= "------------------Logging End-------------------------\r\n";
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     {
146 146
         $api = API::$API[$method];
147 147
         if (!$api) {
148
-            throw new Ks3ClientException($method . " Not Found API");
148
+            throw new Ks3ClientException($method." Not Found API");
149 149
         }
150 150
         if (count($args) !== 0) {
151 151
             if (count($args) > 1 || !is_array($args[0])) {
@@ -159,20 +159,20 @@  discard block
 block discarded – undo
159 159
         $request = new Ks3Request();
160 160
         if (empty($args["Bucket"])) {
161 161
             if ($api["needBucket"]) {
162
-                throw new Ks3ClientException($method . " this api need bucket");
162
+                throw new Ks3ClientException($method." this api need bucket");
163 163
             }
164
-        } else {
164
+        }else {
165 165
             $request->bucket = $args["Bucket"];
166 166
         }
167 167
         $position = $api["objectPostion"] ?? "Key";
168 168
         if (empty($args[$position])) {
169 169
             if ($api["needObject"]) {
170
-                throw new Ks3ClientException($method . " this api need " . $position);
170
+                throw new Ks3ClientException($method." this api need ".$position);
171 171
             }
172
-        } else {
172
+        }else {
173 173
             $key = $args[$position];
174 174
             $preEncoding = mb_detect_encoding($key, array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5"));
175
-            $holder->msg .= "key encoding " . $preEncoding . "\r\n";
175
+            $holder->msg .= "key encoding ".$preEncoding."\r\n";
176 176
             if (strtolower($preEncoding) !== "utf-8") {
177 177
                 $key = iconv($preEncoding, "UTF-8", $key);
178 178
             }
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
         if ($method === "Method") {
183 183
             if (empty($args["Method"])) {
184 184
                 $request->method = "GET";
185
-            } else {
185
+            }else {
186 186
                 $request->method = $args["Method"];
187 187
             }
188
-        } else {
188
+        }else {
189 189
             $request->method = $api["method"];
190 190
         }
191 191
         if (KS3_API_USE_HTTPS) {
192 192
             $request->scheme = "https://";
193
-        } else {
193
+        }else {
194 194
             $request->scheme = "http://";
195 195
         }
196 196
         $request->endpoint = $this->endpoint;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
                 foreach ($index as $key1 => $value1) {
214 214
                     if (!isset($curIndexArg[$value1]) && $value1 !== "*") {
215 215
                         $add = FALSE;
216
-                    } else {
216
+                    }else {
217 217
                         $curkey = $value1;
218 218
                         //星号表示所有,按照暂时的业务,默认星号后面就没了
219 219
                         if ($curkey === "*") {
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
                     continue;
236 236
                 }
237 237
                 if ($required) {
238
-                    throw new Ks3ClientException($method . " param " . $value . " is required");
238
+                    throw new Ks3ClientException($method." param ".$value." is required");
239 239
                 }
240 240
             }
241 241
         }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                 $builderName = $api["body"]["builder"];
245 245
                 $builder = new $builderName();
246 246
                 $request->body = $builder->build($args);
247
-            } else if (isset($api["body"]["position"])) {
247
+            }else if (isset($api["body"]["position"])) {
248 248
                 $position = $api["body"]["position"];
249 249
                 $index = explode("->", $position);
250 250
                 $curIndexArg = $args;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
                 foreach ($index as $key1 => $value1) {
254 254
                     if (!isset($curIndexArg[$value1])) {
255 255
                         $add = FALSE;
256
-                    } else {
256
+                    }else {
257 257
                         $curIndexArg = $curIndexArg[$value1];
258 258
                         $curkey = $value1;
259 259
                     }
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
                 $signer = new $value();
275 275
                 $log = $signer->sign($request, array("accessKey" => $this->accessKey, "secretKey" => $this->secretKey, "args" => $args));
276 276
                 if (!empty($log)) {
277
-                    $holder->msg .= $log . "\r\n";
277
+                    $holder->msg .= $log."\r\n";
278 278
                 }
279 279
             }
280 280
         }
@@ -314,31 +314,31 @@  discard block
 block discarded – undo
314 314
                 $httpRequest->set_write_stream($write_stream);
315 315
             }
316 316
 
317
-            $holder->msg .= "request url->" . serialize($httpRequest->request_url) . "\r\n";
318
-            $holder->msg .= "request headers->" . serialize($httpRequest->request_headers) . "\r\n";
319
-            $holder->msg .= "request body->" . $httpRequest->request_body . "\r\n";
320
-            $holder->msg .= "request read stream length->" . $read_length . "\r\n";
321
-            $holder->msg .= "request read stream seek position->" . $seek_position . "\r\n";
317
+            $holder->msg .= "request url->".serialize($httpRequest->request_url)."\r\n";
318
+            $holder->msg .= "request headers->".serialize($httpRequest->request_headers)."\r\n";
319
+            $holder->msg .= "request body->".$httpRequest->request_body."\r\n";
320
+            $holder->msg .= "request read stream length->".$read_length."\r\n";
321
+            $holder->msg .= "request read stream seek position->".$seek_position."\r\n";
322 322
             $httpRequest->send_request();
323 323
             //print_r($httpRequest);
324 324
             $body = $httpRequest->get_response_body();
325
-            $data = new ResponseCore ($httpRequest->get_response_header(), Utils::replaceNS2($body), $httpRequest->get_response_code());
325
+            $data = new ResponseCore($httpRequest->get_response_header(), Utils::replaceNS2($body), $httpRequest->get_response_code());
326 326
 
327 327
             if ($data->status == 307) {
328 328
                 $respHeaders = $httpRequest->get_response_header();
329 329
                 $location = $respHeaders["location"];
330 330
                 if (strpos($location, "http") === 0) {
331
-                    $holder->msg .= "response code->" . $httpRequest->get_response_code() . "\r\n";
332
-                    $holder->msg .= "response headers->" . serialize($httpRequest->get_response_header()) . "\r\n";
333
-                    $holder->msg .= "response body->" . $body . "\r\n";
334
-                    $holder->msg .= "retry request to " . $location . "\r\n";
331
+                    $holder->msg .= "response code->".$httpRequest->get_response_code()."\r\n";
332
+                    $holder->msg .= "response headers->".serialize($httpRequest->get_response_header())."\r\n";
333
+                    $holder->msg .= "response body->".$body."\r\n";
334
+                    $holder->msg .= "retry request to ".$location."\r\n";
335 335
                     //array($args)详见invoke开头
336 336
                     return $this->invoke($method, array($args), $holder, $location);
337 337
                 }
338 338
             }
339
-            $holder->msg .= "response code->" . $httpRequest->get_response_code() . "\r\n";
340
-            $holder->msg .= "response headers->" . serialize($httpRequest->get_response_header()) . "\r\n";
341
-            $holder->msg .= "response body->" . $body . "\r\n";
339
+            $holder->msg .= "response code->".$httpRequest->get_response_code()."\r\n";
340
+            $holder->msg .= "response headers->".serialize($httpRequest->get_response_header())."\r\n";
341
+            $holder->msg .= "response body->".$body."\r\n";
342 342
             $handlers = explode("->", $api["handler"]);
343 343
             foreach ($handlers as $key => $value) {
344 344
                 $handler = new $value();
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
         }
349 349
 
350 350
         $url = $request->toUrl($this->endpoint);
351
-        $holder->msg .= $url . "\r\n";
351
+        $holder->msg .= $url."\r\n";
352 352
         return $url;
353 353
     }
354 354
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
     {
358 358
         $policy = array();
359 359
 
360
-        $expireTime = Utils::iso8601(time() + $expire);
360
+        $expireTime = Utils::iso8601(time()+$expire);
361 361
         $policy["expiration"] = $expireTime;
362 362
         $postFormData["bucket"] = $bucket;
363 363
         $conditions = array();
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
         foreach ($unknowValueFormFiled as $key => $value) {
370 370
             $condition = array();
371 371
             $condition[] = "starts-with";
372
-            $condition[] = "\$" . $value;
372
+            $condition[] = "\$".$value;
373 373
             $condition[] = "";
374 374
             $conditions[] = $condition;
375 375
         }
Please login to merge, or discard this patch.