Completed
Pull Request — master (#25)
by sabaku
07:41
created
src/Upyun/Api/Form.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 use Upyun\Util;
7 7
 use GuzzleHttp\Client;
8 8
 
9
-class Form extends Rest{
9
+class Form extends Rest {
10 10
 
11 11
     public function upload($path, $stream, $params) {
12 12
         $params['save-key'] = $path;
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 
18 18
         $policy = Util::base64Json($params);
19 19
         $method = 'POST';
20
-        $signature = Signature::getBodySignature($this->config, $method, '/' . $params['bucket'], null, $policy);
20
+        $signature = Signature::getBodySignature($this->config, $method, '/'.$params['bucket'], null, $policy);
21 21
         $client = new Client([
22 22
             'timeout' => $this->config->timeout,
23 23
         ]);
24 24
 
25
-        $url = ($this->config->useSsl ? 'https://' : 'http://') . $this->endpoint;
25
+        $url = ($this->config->useSsl ? 'https://' : 'http://').$this->endpoint;
26 26
 
27 27
         $response = $client->request($method, $url, array(
28 28
             'multipart' => array(
Please login to merge, or discard this patch.
tests/SignatureTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use Upyun\Signature;
4 4
 use Upyun\Config;
5 5
 
6
-class SignatureTest extends \PHPUnit_Framework_TestCase{
6
+class SignatureTest extends \PHPUnit_Framework_TestCase {
7 7
 
8 8
     /**
9 9
      * @var Config;
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
     public function testGetSignature() {
18 18
         $sign = Signature::getSignature($this->config, array('a' => 'a', 'b' => 'b'), Signature::SIGN_MULTIPART, '123');
19
-        $this->assertEquals($sign , '2aa0afd612df8fab4b3fded36c396234');
19
+        $this->assertEquals($sign, '2aa0afd612df8fab4b3fded36c396234');
20 20
     }
21 21
 
22 22
     public function testGetBodySignature() {
Please login to merge, or discard this patch.
src/Upyun/Util.php 1 patch
Spacing   +8 added lines, -8 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();
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Upyun/Api/Rest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             }
Please login to merge, or discard this patch.