@@ -3,7 +3,7 @@ |
||
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; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -require dirname(__DIR__) . '/vendor/autoload.php'; |
|
3 | -$config = require_once __DIR__ . '/config.php'; |
|
2 | +require dirname(__DIR__).'/vendor/autoload.php'; |
|
3 | +$config = require_once __DIR__.'/config.php'; |
|
4 | 4 | |
5 | 5 | define('USER_NAME', $config['user_name']); |
6 | 6 | define('PWD', $config['pwd']); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | define('PIC_SIZE', filesize(PIC_PATH)); |
10 | 10 | |
11 | 11 | function getFileUrl($path) { |
12 | - return "http://" . BUCKET . ".b0.upaiyun.com/" . ltrim($path, '/'); |
|
12 | + return "http://".BUCKET.".b0.upaiyun.com/".ltrim($path, '/'); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | function getUpyunFileSize($path) { |
@@ -3,7 +3,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | )); |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | $params = Util::getHeaderParams($response->getHeaders()); |
122 | 122 | |
123 | 123 | |
124 | - if (! isset($params['x-upyun-list-iter'])) { |
|
125 | - if(is_resource($saveHandler)) { |
|
124 | + if (!isset($params['x-upyun-list-iter'])) { |
|
125 | + if (is_resource($saveHandler)) { |
|
126 | 126 | Psr7\copy_to_stream($response->getBody(), Psr7\stream_for($saveHandler)); |
127 | 127 | return true; |
128 | 128 | } else { |
@@ -206,7 +206,7 @@ discard block |
||
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 |
||
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(); |
@@ -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,7 +57,7 @@ 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 | 62 | if ($this->file && $this->method === 'PUT') { |
63 | 63 | $body = $this->file; |
@@ -18,7 +18,7 @@ discard block |
||
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 |
||
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', |
@@ -17,7 +17,7 @@ discard block |
||
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 |
||
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 |
||
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; |