Completed
Push — master ( c8a547...8676e4 )
by sabaku
03:53
created
src/Upyun/Signature.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@  discard block
 block discarded – undo
10 10
     /**
11 11
      * 获取分块上传接口的签名
12 12
      */
13
-    const SIGN_MULTIPART     = 1;
13
+    const SIGN_MULTIPART = 1;
14 14
     /**
15 15
      * 生成视频处理接口的签名
16 16
      */
17
-    const SIGN_VIDEO         = 2;
17
+    const SIGN_VIDEO = 2;
18 18
     /**
19 19
      * 生成视频处理接口的签名(不需要操作员时使用)
20 20
      */
21
-    const SIGN_VIDEO_NO_OPERATOR   = 3;
21
+    const SIGN_VIDEO_NO_OPERATOR = 3;
22 22
 
23 23
     /**
24 24
      * 获取 Header 签名需要的请求头
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         $headers = array(
40 40
             'Authorization' => $sign,
41 41
             'Date' => $gmtDate,
42
-            'User-agent' => 'Php-Sdk/' . $bucketConfig->getVersion()
42
+            'User-agent' => 'Php-Sdk/'.$bucketConfig->getVersion()
43 43
         );
44 44
         return $headers;
45 45
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         return array(
59 59
             'Authorization' => "UpYun {$bucketConfig->bucketName}:{$bucketConfig->operatorName}:$sign",
60 60
             'Date' => $gmtDate,
61
-            'User-agent' => 'Php-Sdk/' . $bucketConfig->getVersion() . ' (purge api)'
61
+            'User-agent' => 'Php-Sdk/'.$bucketConfig->getVersion().' (purge api)'
62 62
         );
63 63
     }
64 64
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             $data[] = $contentMd5;
91 91
         }
92 92
         $signature = base64_encode(hash_hmac('sha1', implode('&', $data), $bucketConfig->operatorPassword, true));
93
-        return 'UPYUN ' . $bucketConfig->operatorName . ':' . $signature;
93
+        return 'UPYUN '.$bucketConfig->operatorName.':'.$signature;
94 94
     }
95 95
 
96 96
     public static function getSignature(Config $bucketConfig, $data, $type, $tokenSecret = '') {
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                     $string .= $tokenSecret ? $tokenSecret : $bucketConfig->getFormApiKey();
109 109
                     break;
110 110
                 case self::SIGN_VIDEO:
111
-                    $string = $bucketConfig->operatorName . $string . $bucketConfig->operatorPassword;
111
+                    $string = $bucketConfig->operatorName.$string.$bucketConfig->operatorPassword;
112 112
                     break;
113 113
                 case self::SIGN_VIDEO_NO_OPERATOR:
114 114
                     break;
Please login to merge, or discard this patch.
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.