@@ -14,12 +14,18 @@ discard block |
||
14 | 14 | $this->secretKey = $secretKey; |
15 | 15 | } |
16 | 16 | |
17 | + /** |
|
18 | + * @param string $data |
|
19 | + */ |
|
17 | 20 | public function sign($data) |
18 | 21 | { |
19 | 22 | $hmac = hash_hmac('sha1', $data, $this->secretKey, true); |
20 | 23 | return $this->accessKey . ':' . \Qiniu\base64_urlSafeEncode($hmac); |
21 | 24 | } |
22 | 25 | |
26 | + /** |
|
27 | + * @param string $data |
|
28 | + */ |
|
23 | 29 | public function signWithData($data) |
24 | 30 | { |
25 | 31 | $data = \Qiniu\base64_urlSafeEncode($data); |
@@ -120,6 +126,9 @@ discard block |
||
120 | 126 | 'asyncOps', |
121 | 127 | ); |
122 | 128 | |
129 | + /** |
|
130 | + * @param boolean $strictPolicy |
|
131 | + */ |
|
123 | 132 | private static function copyPolicy(&$policy, $originPolicy, $strictPolicy) |
124 | 133 | { |
125 | 134 | if ($originPolicy === null) { |
@@ -136,6 +145,9 @@ discard block |
||
136 | 145 | return $policy; |
137 | 146 | } |
138 | 147 | |
148 | + /** |
|
149 | + * @param string $contentType |
|
150 | + */ |
|
139 | 151 | public function authorization($url, $body = null, $contentType = null) |
140 | 152 | { |
141 | 153 | $authorization = 'QBox ' . $this->signRequest($url, $body, $contentType); |
@@ -19,6 +19,9 @@ discard block |
||
19 | 19 | return self::sendRequest($request); |
20 | 20 | } |
21 | 21 | |
22 | + /** |
|
23 | + * @param string $name |
|
24 | + */ |
|
22 | 25 | public static function multipartPost( |
23 | 26 | $url, |
24 | 27 | $fields, |
@@ -71,6 +74,9 @@ discard block |
||
71 | 74 | return $ua; |
72 | 75 | } |
73 | 76 | |
77 | + /** |
|
78 | + * @param Request $request |
|
79 | + */ |
|
74 | 80 | private static function sendRequest($request) |
75 | 81 | { |
76 | 82 | $t1 = microtime(true); |
@@ -121,6 +127,9 @@ discard block |
||
121 | 127 | return new Response($code, $duration, $headers, $body, null); |
122 | 128 | } |
123 | 129 | |
130 | + /** |
|
131 | + * @param string $raw |
|
132 | + */ |
|
124 | 133 | private static function parseHeaders($raw) |
125 | 134 | { |
126 | 135 | $headers = array(); |
@@ -248,24 +248,37 @@ discard block |
||
248 | 248 | return $this->rsPost('/batch', $params); |
249 | 249 | } |
250 | 250 | |
251 | + /** |
|
252 | + * @param string $path |
|
253 | + * @param string $body |
|
254 | + */ |
|
251 | 255 | private function rsPost($path, $body = null) |
252 | 256 | { |
253 | 257 | $url = Config::RS_HOST . $path; |
254 | 258 | return $this->post($url, $body); |
255 | 259 | } |
256 | 260 | |
261 | + /** |
|
262 | + * @param string $path |
|
263 | + */ |
|
257 | 264 | private function rsGet($path) |
258 | 265 | { |
259 | 266 | $url = Config::RS_HOST . $path; |
260 | 267 | return $this->get($url); |
261 | 268 | } |
262 | 269 | |
270 | + /** |
|
271 | + * @param string $path |
|
272 | + */ |
|
263 | 273 | private function ioPost($path, $body = null) |
264 | 274 | { |
265 | 275 | $url = Config::IO_HOST . $path; |
266 | 276 | return $this->post($url, $body); |
267 | 277 | } |
268 | 278 | |
279 | + /** |
|
280 | + * @param string $url |
|
281 | + */ |
|
269 | 282 | private function get($url) |
270 | 283 | { |
271 | 284 | $headers = $this->auth->authorization($url); |
@@ -276,6 +289,9 @@ discard block |
||
276 | 289 | return array($ret->json(), null); |
277 | 290 | } |
278 | 291 | |
292 | + /** |
|
293 | + * @param string $url |
|
294 | + */ |
|
279 | 295 | private function post($url, $body) |
280 | 296 | { |
281 | 297 | $headers = $this->auth->authorization($url, $body, 'application/x-www-form-urlencoded'); |
@@ -316,6 +332,9 @@ discard block |
||
316 | 332 | return self::oneKeyBatch('stat', $bucket, $keys); |
317 | 333 | } |
318 | 334 | |
335 | + /** |
|
336 | + * @param string $operation |
|
337 | + */ |
|
319 | 338 | private static function oneKeyBatch($operation, $bucket, $keys) |
320 | 339 | { |
321 | 340 | $data = array(); |
@@ -325,6 +344,9 @@ discard block |
||
325 | 344 | return $data; |
326 | 345 | } |
327 | 346 | |
347 | + /** |
|
348 | + * @param string $operation |
|
349 | + */ |
|
328 | 350 | private static function twoKeyBatch($operation, $source_bucket, $key_pairs, $target_bucket) |
329 | 351 | { |
330 | 352 | if ($target_bucket === null) { |