Passed
Pull Request — master (#54)
by
unknown
10:38
created
src/Upyun/Api/Rest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
     public function __construct(Config $config)
30 30
     {
31 31
         $this->config   = $config;
32
-        $this->endpoint = $config->getProtocol() . Config::$restApiEndPoint . '/' . $config->serviceName;
32
+        $this->endpoint = $config->getProtocol().Config::$restApiEndPoint.'/'.$config->serviceName;
33 33
     }
34 34
 
35 35
     public function request($method, $storagePath)
36 36
     {
37 37
         $this->method = strtoupper($method);
38
-        $this->storagePath = '/' . ltrim($storagePath, '/');
38
+        $this->storagePath = '/'.ltrim($storagePath, '/');
39 39
         return $this;
40 40
     }
41 41
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             'timeout' => $this->config->timeout,
63 63
         ]);
64 64
 
65
-        $url = $this->endpoint . $this->storagePath;
65
+        $url = $this->endpoint.$this->storagePath;
66 66
         $body = null;
67 67
         if ($this->file && $this->method === 'PUT') {
68 68
             $body = $this->file;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
     public function toRequest()
110 110
     {
111
-        $url = $this->endpoint . $this->storagePath;
111
+        $url = $this->endpoint.$this->storagePath;
112 112
         $body = null;
113 113
         if ($this->file && $this->method === 'PUT') {
114 114
             $body = $this->file;
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
@@ -36,9 +36,9 @@
 block discarded – undo
36 36
         if (! $useBlock) {
37 37
             $req = new Rest($this->config);
38 38
             return $req->request('PUT', $path)
39
-                       ->withHeaders($params)
40
-                       ->withFile($stream)
41
-                       ->send();
39
+                        ->withHeaders($params)
40
+                        ->withFile($stream)
41
+                        ->send();
42 42
         } elseif ($this->config->uploadType === 'BLOCK_PARALLEL') {
43 43
             return $this->concurrentPointUpload($path, $stream, $params);
44 44
         } else {
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
             return $req->upload($path, $stream, $params);
34 34
         }
35 35
 
36
-        if (! $useBlock) {
36
+        if (!$useBlock) {
37 37
             $req = new Rest($this->config);
38 38
             return $req->request('PUT', $path)
39 39
                        ->withHeaders($params)
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         $headers = array();
62 62
         if (is_array($params)) {
63 63
             foreach ($params as $key => $val) {
64
-                $headers['X-Upyun-Meta-' . $key] = $val;
64
+                $headers['X-Upyun-Meta-'.$key] = $val;
65 65
             }
66 66
         }
67 67
         $res = $req->request('PUT', $path)
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         $headers = array();
140 140
         if (is_array($params)) {
141 141
             foreach ($params as $key => $val) {
142
-                $headers['X-Upyun-Meta-' . $key] = $val;
142
+                $headers['X-Upyun-Meta-'.$key] = $val;
143 143
             }
144 144
         }
145 145
         $res = $req->request('PUT', $path)
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
         $init = Util::getHeaderParams($res->getHeaders());
158 158
         $uuid = $init['x-upyun-multi-uuid'];
159
-        $requests = function ($req, $path, $stream, $uuid) {
159
+        $requests = function($req, $path, $stream, $uuid) {
160 160
             $blockSize = 1024 * 1024;
161 161
             $total = ceil($stream->getSize() / $blockSize);
162 162
             for ($i = 0; $i < $total; $i++) {
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
         ]);
177 177
         $pool = new Pool($client, $requests($req, $path, $stream, $uuid), [
178 178
             'concurrency' => $this->config->concurrency,
179
-            'fulfilled' => function ($res) {
179
+            'fulfilled' => function($res) {
180 180
                 if ($res->getStatusCode() !== 204) {
181 181
                     throw new \Exception('upload request failed when poinit upload!');
182 182
                 }
183 183
             },
184
-            'rejected' => function () {
184
+            'rejected' => function() {
185 185
                 throw new \Exception('upload request failed when poinit upload!');
186 186
             },
187 187
         ]);
Please login to merge, or discard this patch.
tests/UpyunTest.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         $config->setFormApiKey('Mv83tlocuzkmfKKUFbz2s04FzTw=');
24 24
         $config->processNotifyUrl = 'http://localhost:9999';
25 25
         self::$upyun        = new Upyun($config);
26
-        self::$tempFilePath = __DIR__ . '/assets/test.txt';
26
+        self::$tempFilePath = __DIR__.'/assets/test.txt';
27 27
         touch(self::$tempFilePath);
28 28
     }
29 29
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     public function testWriteStream()
45 45
     {
46 46
         $filename = 'test.jpeg';
47
-        $f = fopen(__DIR__ . '/assets/sample.jpeg', 'rb');
47
+        $f = fopen(__DIR__.'/assets/sample.jpeg', 'rb');
48 48
         if (!$f) {
49 49
             throw new \Exception('open test file failed!');
50 50
         }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     {
58 58
         $filename = 'test_async.jpeg';
59 59
         $newFilename = 'test_async.png';
60
-        $f = fopen(__DIR__ . '/assets/sample.jpeg', 'rb');
60
+        $f = fopen(__DIR__.'/assets/sample.jpeg', 'rb');
61 61
         if (!$f) {
62 62
             throw new \Exception('open test file failed!');
63 63
         }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         try {
82 82
             $fs->write('test.txt', 'test file content');
83 83
         } catch (\Exception $e) {
84
-            return ;
84
+            return;
85 85
         }
86 86
         throw new \Exception('should get sign error.');
87 87
     }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         try {
117 117
             self::$upyun->read('test-delete.txt');
118 118
         } catch (\Exception $e) {
119
-            return ;
119
+            return;
120 120
         }
121 121
         throw new \Exception('delete file failed');
122 122
     }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
     public function testProcess()
219 219
     {
220 220
         $source = 'php-sdk-sample.mp4';
221
-        self::$upyun->write($source, fopen(__DIR__ . '/assets/SampleVideo_640x360_1mb.mp4', 'r'));
221
+        self::$upyun->write($source, fopen(__DIR__.'/assets/SampleVideo_640x360_1mb.mp4', 'r'));
222 222
         $result = self::$upyun->process(array(
223 223
             array('type' => 'video', 'avopts' => '/s/240p(4:3)/as/1/r/30', 'return_info' => true, 'save_as' => '/video/result.mp4')
224 224
         ), Upyun::$PROCESS_TYPE_MEDIA, $source);
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
     public function testAvMeta()
258 258
     {
259 259
         $source = 'php-sdk-sample.mp4';
260
-        self::$upyun->write($source, fopen(__DIR__ . '/assets/SampleVideo_640x360_1mb.mp4', 'r'));
260
+        self::$upyun->write($source, fopen(__DIR__.'/assets/SampleVideo_640x360_1mb.mp4', 'r'));
261 261
         $result = self::$upyun->avMeta('/php-sdk-sample.mp4');
262 262
         $this->assertTrue(count($result) === 2);
263 263
         $this->assertTrue($result['streams'][0]['type'] === 'video');
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
     public function testSnapshot()
267 267
     {
268 268
         $source = 'php-sdk-sample.mp4';
269
-        self::$upyun->write($source, fopen(__DIR__ . '/assets/SampleVideo_640x360_1mb.mp4', 'r'));
269
+        self::$upyun->write($source, fopen(__DIR__.'/assets/SampleVideo_640x360_1mb.mp4', 'r'));
270 270
         $result = self::$upyun->snapshot('/php-sdk-sample.mp4', '/snapshot.jpg', '00:00:01', '720x480', 'jpg');
271 271
         $this->assertTrue($result['status_code'] === 200);
272 272
     }
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
         $config->setUploadType('BLOCK_PARALLEL');
278 278
         $upyun = new Upyun($config);
279 279
         $filename = 'test_parallel.jpeg';
280
-        $upyun->write($filename, fopen(__DIR__ . '/assets/sample.jpeg', 'rb'));
280
+        $upyun->write($filename, fopen(__DIR__.'/assets/sample.jpeg', 'rb'));
281 281
 
282 282
         $size = getUpyunFileSize($filename);
283 283
         $this->assertEquals($size, PIC_SIZE);
Please login to merge, or discard this patch.