@@ -3,7 +3,7 @@ discard block |
||
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 |
||
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 |
||
23 | 23 | |
24 | 24 | public static function parseDir($body) { |
25 | 25 | $files = array(); |
26 | - if(!$body) { |
|
26 | + if (!$body) { |
|
27 | 27 | return array(); |
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; |
@@ -64,16 +64,16 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public static function encodeURI($url) { |
66 | 66 | $unescaped = array( |
67 | - '%2D'=>'-','%5F'=>'_','%2E'=>'.','%21'=>'!', '%7E'=>'~', |
|
67 | + '%2D'=>'-', '%5F'=>'_', '%2E'=>'.', '%21'=>'!', '%7E'=>'~', |
|
68 | 68 | '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')' |
69 | 69 | ); |
70 | 70 | $reserved = array( |
71 | - '%3B'=>';','%2C'=>',','%2F'=>'/','%3F'=>'?','%3A'=>':', |
|
72 | - '%40'=>'@','%26'=>'&','%3D'=>'=','%2B'=>'+','%24'=>'$' |
|
71 | + '%3B'=>';', '%2C'=>',', '%2F'=>'/', '%3F'=>'?', '%3A'=>':', |
|
72 | + '%40'=>'@', '%26'=>'&', '%3D'=>'=', '%2B'=>'+', '%24'=>'$' |
|
73 | 73 | ); |
74 | 74 | $score = array( |
75 | 75 | '%23'=>'#' |
76 | 76 | ); |
77 | - return strtr(rawurlencode($url), array_merge($reserved,$unescaped,$score)); |
|
77 | + return strtr(rawurlencode($url), array_merge($reserved, $unescaped, $score)); |
|
78 | 78 | } |
79 | 79 | } |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | |
28 | 28 | public function __construct(Config $config) { |
29 | 29 | $this->config = $config; |
30 | - $this->endpoint = Config::$restApiEndPoint . '/' . $config->bucketName; |
|
30 | + $this->endpoint = Config::$restApiEndPoint.'/'.$config->bucketName; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function request($method, $storagePath) { |
34 | 34 | $this->method = strtoupper($method); |
35 | - $this->storagePath = '/' . ltrim($storagePath, '/'); |
|
35 | + $this->storagePath = '/'.ltrim($storagePath, '/'); |
|
36 | 36 | return $this; |
37 | 37 | } |
38 | 38 | |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | 'timeout' => $this->config->timeout, |
58 | 58 | ]); |
59 | 59 | |
60 | - $url = ($this->config->useSsl ? 'https://' : 'http://') . $this->endpoint . $this->storagePath; |
|
60 | + $url = ($this->config->useSsl ? 'https://' : 'http://').$this->endpoint.$this->storagePath; |
|
61 | 61 | $body = null; |
62 | - if($this->file && $this->method === 'PUT') { |
|
62 | + if ($this->file && $this->method === 'PUT') { |
|
63 | 63 | $body = $this->file; |
64 | 64 | } |
65 | 65 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $this->method, |
74 | 74 | $request->getUri()->getPath() |
75 | 75 | ); |
76 | - foreach($authHeader as $head => $value) { |
|
76 | + foreach ($authHeader as $head => $value) { |
|
77 | 77 | $request = $request->withHeader($head, $value); |
78 | 78 | } |
79 | 79 | $response = $client->send($request, [ |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | public function withHeaders($headers) { |
94 | - if(is_array($headers)) { |
|
94 | + if (is_array($headers)) { |
|
95 | 95 | foreach ($headers as $header => $value) { |
96 | 96 | $this->withHeader($header, $value); |
97 | 97 | } |