Completed
Pull Request — master (#26)
by sabaku
03:35
created
tests/SignatureTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 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;
Please login to merge, or discard this patch.
tests/UpyunTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use Upyun\Config;
4 4
 use Upyun\Upyun;
5 5
 
6
-class UpyunTest extends \PHPUnit_Framework_TestCase{
6
+class UpyunTest extends \PHPUnit_Framework_TestCase {
7 7
 
8 8
     /**
9 9
      * @var Upyun
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
         $config->setFormApiKey('Mv83tlocuzkmfKKUFbz2s04FzTw=');
21 21
         $config->processNotifyUrl = 'http://localhost:9999';
22 22
         self::$upyun        = new Upyun($config);
23
-        self::$tempFilePath = __DIR__ . '/assets/test.txt';
23
+        self::$tempFilePath = __DIR__.'/assets/test.txt';
24 24
         touch(self::$tempFilePath);
25 25
     }
26 26
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
     public function testWriteStream() {
40 40
         $filename = 'test.jpeg';
41
-        $f = fopen(__DIR__ . '/assets/sample.jpeg', 'rb');
41
+        $f = fopen(__DIR__.'/assets/sample.jpeg', 'rb');
42 42
         if (!$f) {
43 43
             throw new \Exception('open test file failed!');
44 44
         }
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     public function testWriteWithAsyncProcess() {
51 51
         $filename = 'test_async.jpeg';
52 52
         $newFilename = 'test_async.png';
53
-        $f = fopen(__DIR__ . '/assets/sample.jpeg', 'rb');
53
+        $f = fopen(__DIR__.'/assets/sample.jpeg', 'rb');
54 54
         if (!$f) {
55 55
             throw new \Exception('open test file failed!');
56 56
         }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         try {
74 74
             $fs->write('test.txt', 'test file content');
75 75
         } catch (\Exception $e) {
76
-            return ;
76
+            return;
77 77
         }
78 78
         throw new \Exception('should get sign error.');
79 79
     }
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         try {
106 106
             self::$upyun->read('test-delete.txt');
107 107
         } catch (\Exception $e) {
108
-            return ;
108
+            return;
109 109
         }
110 110
         throw new \Exception('delete file failed');
111 111
     }
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 
190 190
     public function testProcess() {
191 191
         $source = 'php-sdk-sample.mp4';
192
-        self::$upyun->write($source, fopen(__DIR__ . '/assets/SampleVideo_640x360_1mb.mp4', 'r'));
192
+        self::$upyun->write($source, fopen(__DIR__.'/assets/SampleVideo_640x360_1mb.mp4', 'r'));
193 193
         $result = self::$upyun->process($source, array(
194 194
             array('type' => 'video', 'avopts' => '/s/240p(4:3)/as/1/r/30', 'return_info' => true, 'save_as' => '/video/result.mp4')
195 195
         ));
Please login to merge, or discard this patch.
src/Upyun/Api/Rest.php 1 patch
Spacing   +3 added lines, -3 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,7 +57,7 @@  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 62
         if ($this->file && $this->method === 'PUT') {
63 63
             $body = $this->file;
Please login to merge, or discard this patch.
src/Upyun/Api/Multi.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     public function __construct(Config $config) {
19 19
         $this->config = $config;
20 20
         $this->url = ($this->config->useSsl ? 'https://' : 'http://') . Config::ED_FORM . '/'.
21
-                     $this->config->bucketName;
21
+                        $this->config->bucketName;
22 22
     }
23 23
 
24 24
     /**
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
         $multipart = [];
106 106
         foreach ($postData as $key => $value) {
107
-           $multipart[] = ['name' => $key, 'contents' => $value];
107
+            $multipart[] = ['name' => $key, 'contents' => $value];
108 108
         }
109 109
         $multipart[] = [
110 110
             'name' => 'file',
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
     public function __construct(Config $config) {
19 19
         $this->config = $config;
20
-        $this->url = ($this->config->useSsl ? 'https://' : 'http://') . Config::ED_FORM . '/'.
20
+        $this->url = ($this->config->useSsl ? 'https://' : 'http://').Config::ED_FORM.'/'.
21 21
                      $this->config->bucketName;
22 22
     }
23 23
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      * @throws \Exception
32 32
      */
33 33
     public function upload($path, $stream, $fileHash, $params = []) {
34
-        $path = '/' . ltrim($path, '/');
34
+        $path = '/'.ltrim($path, '/');
35 35
         $initInfo = $this->initRequest($path, $stream, $fileHash, $params);
36 36
         $blockStatus = $initInfo->status;
37 37
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
         $multipart[] = [
110 110
             'name' => 'file',
111 111
             'contents' => $fileBlock,
112
-            'filename' => 'file',  //this value must be file
112
+            'filename' => 'file', //this value must be file
113 113
             'headers' => ['Content-Type' => 'application/octet-stream']
114 114
         ];
115 115
         $postData['file'] = $fileBlock;
Please login to merge, or discard this patch.
tests/bootstrap.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@
 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
-    return "http://" . BUCKET . ".b0.upaiyun.com/" . ltrim($path, '/');
11
+    return "http://".BUCKET.".b0.upaiyun.com/".ltrim($path, '/');
12 12
 }
13 13
 
14 14
 function getUpyunFileSize($path) {
Please login to merge, or discard this patch.
src/Upyun/Uploader.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@
 block discarded – undo
31 31
         if (! $useBlock) {
32 32
             $req = new Rest($this->config);
33 33
             return $req->request('PUT', $path)
34
-                       ->withHeaders($params)
35
-                       ->withFile($stream)
36
-                       ->send();
34
+                        ->withHeaders($params)
35
+                        ->withFile($stream)
36
+                        ->send();
37 37
         } else {
38 38
             return $this->pointUpload($path, $stream, $params);
39 39
         }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
             return $req->upload($path, $stream, $params);
29 29
         }
30 30
 
31
-        if (! $useBlock) {
31
+        if (!$useBlock) {
32 32
             $req = new Rest($this->config);
33 33
             return $req->request('PUT', $path)
34 34
                        ->withHeaders($params)
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         $headers = array();
54 54
         if (is_array($params)) {
55 55
             foreach ($params as $key => $val) {
56
-                $headers['X-Upyun-Meta-' . $key] = $val;
56
+                $headers['X-Upyun-Meta-'.$key] = $val;
57 57
             }
58 58
         }
59 59
         $res = $req->request('PUT', $path)
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         if ($this->config->uploadType === 'BLOCK') {
107 107
             return true;
108 108
         } else if ($this->config->uploadType === 'AUTO' &&
109
-                  $fileSize >= $this->config->sizeBoundary ) {
109
+                  $fileSize >= $this->config->sizeBoundary) {
110 110
             return true;
111 111
         } else {
112 112
             return false;
Please login to merge, or discard this patch.
src/Upyun/Config.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -87,17 +87,17 @@  discard block
 block discarded – undo
87 87
     /**
88 88
      * 分块上传接口请求地址
89 89
      */
90
-    const ED_FORM            = 'm0.api.upyun.com';
90
+    const ED_FORM = 'm0.api.upyun.com';
91 91
 
92 92
     /**
93 93
      * 异步云处理接口地址
94 94
      */
95
-    const ED_VIDEO           = 'p0.api.upyun.com';
95
+    const ED_VIDEO = 'p0.api.upyun.com';
96 96
 
97 97
     /**
98 98
      * 刷新接口地址
99 99
      */
100
-    const ED_PURGE           = 'http://purge.upyun.com/purge/';
100
+    const ED_PURGE = 'http://purge.upyun.com/purge/';
101 101
 
102 102
     public function __construct($bucketName, $operatorName, $operatorPassword) {
103 103
         $this->bucketName = $bucketName;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     }
113 113
 
114 114
     public function getFormApiKey() {
115
-        if (! $this->formApiKey) {
115
+        if (!$this->formApiKey) {
116 116
             throw new \Exception('form api key is empty.');
117 117
         }
118 118
 
Please login to merge, or discard this patch.
src/Upyun/Upyun.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         $params = Util::getHeaderParams($response->getHeaders());
122 122
 
123 123
 
124
-        if (! isset($params['x-upyun-list-iter'])) {
124
+        if (!isset($params['x-upyun-list-iter'])) {
125 125
             if (is_resource($saveHandler)) {
126 126
                 Psr7\copy_to_stream($response->getBody(), Psr7\stream_for($saveHandler));
127 127
                 return true;
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
      * @throws \Exception
207 207
      */
208 208
     public function createDir($path) {
209
-        $path = rtrim($path, '/') . '/';
209
+        $path = rtrim($path, '/').'/';
210 210
         $req = new Rest($this->config);
211 211
         $res = $req->request('POST', $path)
212 212
             ->withHeader('folder', 'true')
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
      * @throws \Exception
235 235
      */
236 236
     public function usage($path = '/') {
237
-        $path = rtrim($path, '/') . '/';
237
+        $path = rtrim($path, '/').'/';
238 238
         $req = new Rest($this->config);
239
-        $response = $req->request('GET', $path . '?usage')
239
+        $response = $req->request('GET', $path.'?usage')
240 240
             ->send();
241 241
 
242 242
         return $response->getBody()->getContents();
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
@@ -64,16 +64,16 @@
 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.