Skip to content

Commit 695367c

Browse files
committed
feat format for psr rules
``` php-cs-fixer fix ./ ```
1 parent b84e8b7 commit 695367c

16 files changed

+195
-107
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
vendor
44
composer.lock
55
release*
6+
.php_cs.cache

RoboFile.php

+11-9
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,35 @@
44
*
55
* @see http://robo.li/
66
*/
7-
class RoboFile extends \Robo\Tasks {
8-
/**
9-
* Creates release zip
10-
*
7+
class RoboFile extends \Robo\Tasks
8+
{
9+
/**
10+
* Creates release zip
11+
*
1112
* @param string $version
1213
* @see https://gist.github.com/Rarst/5a8a65478755539770df653c4575219a
13-
*/
14-
public function release($version) {
14+
*/
15+
public function release($version)
16+
{
1517
$package = 'upyun/sdk';
1618
$name = 'php-sdk';
1719
$collection = $this->collectionBuilder();
1820
$workingPath = __DIR__ . DIRECTORY_SEPARATOR . $collection->workDir("release");
1921
$collection->taskExec("composer create-project {$package} {$name} {$version}")
2022
->dir($workingPath)
21-
->arg('--prefer-dist')
23+
->arg('--prefer-dist')
2224
->arg('--no-dev')
2325
->arg('-vvv')
2426
->taskExec('composer dump-autoload --optimize')
2527
->dir($workingPath . DIRECTORY_SEPARATOR . $name)
2628
->arg('-vvv');
2729
$collection->run();
2830

29-
$zipFile = "release/{$name}-{$version}.zip";
31+
$zipFile = "release/{$name}-{$version}.zip";
3032
$this->_remove($zipFile);
3133
$this->taskPack($zipFile)
3234
->addDir("php-sdk", __DIR__ . "/release/php-sdk")
3335
->run();
3436
$this->_deleteDir("release/$name");
35-
}
37+
}
3638
}

examples/list-all-file.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
));
1717

1818
if (is_array($list['files'])) {
19-
foreach($list['files'] as $file) {
19+
foreach ($list['files'] as $file) {
2020
$total++;
2121
if ($file['type'] === 'N') {
2222
echo '文件名: ';
@@ -28,9 +28,8 @@
2828
echo ' 修改时间:' . date('Y-m-d H:i:s', $file['time']);
2929
echo "\n";
3030
}
31-
3231
}
3332
$start = $list['iter'];
34-
} while(!$list['is_end']);
33+
} while (!$list['is_end']);
3534

3635
echo '总共存有文件 ' . $total . '';

src/Upyun/Api/Form.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
use Upyun\Util;
77
use GuzzleHttp\Client;
88

9-
class Form extends Rest{
10-
11-
public function upload($path, $stream, $params) {
9+
class Form extends Rest
10+
{
11+
public function upload($path, $stream, $params)
12+
{
1213
$params['save-key'] = $path;
1314
$params['bucket'] = $this->config->bucketName;
1415
if (!isset($params['expiration'])) {

src/Upyun/Api/Multi.php

+13-7
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77
use Upyun\Signature;
88
use Upyun\Util;
99

10-
class Multi {
10+
class Multi
11+
{
1112
/**
1213
* @var Config
1314
*/
1415
protected $config;
1516

1617
protected $url;
1718

18-
public function __construct(Config $config) {
19+
public function __construct(Config $config)
20+
{
1921
$this->config = $config;
2022
$this->url = ($this->config->useSsl ? 'https://' : 'http://') . Config::ED_FORM . '/'.
2123
$this->config->bucketName;
@@ -30,7 +32,8 @@ public function __construct(Config $config) {
3032
* @return Psr7\Response
3133
* @throws \Exception
3234
*/
33-
public function upload($path, $stream, $fileHash, $params = []) {
35+
public function upload($path, $stream, $fileHash, $params = [])
36+
{
3437
$path = '/' . ltrim($path, '/');
3538
$initInfo = $this->initRequest($path, $stream, $fileHash, $params);
3639
$blockStatus = $initInfo->status;
@@ -51,7 +54,8 @@ public function upload($path, $stream, $fileHash, $params = []) {
5154
}
5255
}
5356

54-
private function initRequest($path, Psr7\Stream $stream, $fileHash, $params) {
57+
private function initRequest($path, Psr7\Stream $stream, $fileHash, $params)
58+
{
5559
$metaData = array(
5660
'expiration' => time() + $this->config->blockExpiration,
5761
'file_blocks' => ceil($stream->getSize() / $this->config->maxBlockSize),
@@ -78,7 +82,8 @@ private function initRequest($path, Psr7\Stream $stream, $fileHash, $params) {
7882
return $initInfo;
7983
}
8084

81-
private function blockUpload($blocksInfo, $blockId, Psr7\Stream $stream, $params = []) {
85+
private function blockUpload($blocksInfo, $blockId, Psr7\Stream $stream, $params = [])
86+
{
8287
$startPosition = $blockId * $this->config->maxBlockSize;
8388
$endPosition = $blockId >= $blocksInfo->blocks - 1 ? $stream->getSize() : $startPosition + $this->config->maxBlockSize;
8489

@@ -104,7 +109,7 @@ private function blockUpload($blocksInfo, $blockId, Psr7\Stream $stream, $params
104109

105110
$multipart = [];
106111
foreach ($postData as $key => $value) {
107-
$multipart[] = ['name' => $key, 'contents' => $value];
112+
$multipart[] = ['name' => $key, 'contents' => $value];
108113
}
109114
$multipart[] = [
110115
'name' => 'file',
@@ -122,7 +127,8 @@ private function blockUpload($blocksInfo, $blockId, Psr7\Stream $stream, $params
122127
return json_decode($response->getBody()->getContents());
123128
}
124129

125-
private function endRequest($initInfo, $data = array()) {
130+
private function endRequest($initInfo, $data = array())
131+
{
126132
$metaData = array();
127133
$metaData['save_token'] = $initInfo->save_token;
128134
$metaData['expiration'] = $initInfo->expired_at;

src/Upyun/Api/Pretreat.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use Upyun\Signature;
88
use Upyun\Util;
99

10-
11-
class Pretreat {
10+
class Pretreat
11+
{
1212

1313
/**
1414
* @var Config
@@ -17,11 +17,13 @@ class Pretreat {
1717

1818
protected $url = 'http://p0.api.upyun.com';
1919

20-
public function __construct(Config $config) {
20+
public function __construct(Config $config)
21+
{
2122
$this->config = $config;
2223
}
2324

24-
public function process($source, $tasks) {
25+
public function process($source, $tasks)
26+
{
2527
$encodedTasks = Util::base64Json($tasks);
2628

2729
$client = new Client([
@@ -50,7 +52,8 @@ public function process($source, $tasks) {
5052
}
5153

5254

53-
public function query($taskIds, $path) {
55+
public function query($taskIds, $path)
56+
{
5457
$client = new Client([
5558
'timeout' => $this->config->timeout,
5659
]);

src/Upyun/Api/Rest.php

+14-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
use Upyun\Signature;
99
use Upyun\Util;
1010

11-
class Rest {
11+
class Rest
12+
{
1213
/**
1314
* @var Config
1415
*/
@@ -25,12 +26,14 @@ class Rest {
2526
protected $file;
2627

2728

28-
public function __construct(Config $config) {
29+
public function __construct(Config $config)
30+
{
2931
$this->config = $config;
3032
$this->endpoint = Config::$restApiEndPoint . '/' . $config->bucketName;
3133
}
3234

33-
public function request($method, $storagePath) {
35+
public function request($method, $storagePath)
36+
{
3437
$this->method = strtoupper($method);
3538
$this->storagePath = '/' . ltrim($storagePath, '/');
3639
return $this;
@@ -42,7 +45,8 @@ public function request($method, $storagePath) {
4245
*
4346
* @return $this
4447
*/
45-
public function withFile($file) {
48+
public function withFile($file)
49+
{
4650
$stream = Psr7\stream_for($file);
4751
$this->file = $stream;
4852

@@ -52,7 +56,8 @@ public function withFile($file) {
5256
/**
5357
* @return mixed|\Psr\Http\Message\ResponseInterface
5458
*/
55-
public function send() {
59+
public function send()
60+
{
5661
$client = new Client([
5762
'timeout' => $this->config->timeout,
5863
]);
@@ -83,14 +88,16 @@ public function send() {
8388
return $response;
8489
}
8590

86-
public function withHeader($header, $value) {
91+
public function withHeader($header, $value)
92+
{
8793
$header = strtolower(trim($header));
8894

8995
$this->headers[$header] = $value;
9096
return $this;
9197
}
9298

93-
public function withHeaders($headers) {
99+
public function withHeaders($headers)
100+
{
94101
if (is_array($headers)) {
95102
foreach ($headers as $header => $value) {
96103
$this->withHeader($header, $value);

src/Upyun/Config.php

+13-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
*
77
* @package Upyun
88
*/
9-
class Config {
9+
class Config
10+
{
1011
/**
1112
* @var string 服务名称
1213
*/
@@ -99,31 +100,36 @@ class Config {
99100
*/
100101
const ED_PURGE = 'http://purge.upyun.com/purge/';
101102

102-
public function __construct($bucketName, $operatorName, $operatorPassword) {
103+
public function __construct($bucketName, $operatorName, $operatorPassword)
104+
{
103105
$this->bucketName = $bucketName;
104106
$this->operatorName = $operatorName;
105107
$this->setOperatorPassword($operatorPassword);
106108
$this->useSsl = false;
107109
self::$restApiEndPoint = self::ED_AUTO;
108110
}
109111

110-
public function setOperatorPassword($operatorPassword) {
112+
public function setOperatorPassword($operatorPassword)
113+
{
111114
$this->operatorPassword = md5($operatorPassword);
112115
}
113116

114-
public function getFormApiKey() {
117+
public function getFormApiKey()
118+
{
115119
if (! $this->formApiKey) {
116120
throw new \Exception('form api key is empty.');
117121
}
118122

119-
return $this->formApiKey;
123+
return $this->formApiKey;
120124
}
121125

122-
public function setFormApiKey($key) {
126+
public function setFormApiKey($key)
127+
{
123128
$this->formApiKey = $key;
124129
}
125130

126-
public function getVersion() {
131+
public function getVersion()
132+
{
127133
return $this->version;
128134
}
129135
}

src/Upyun/Signature.php

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22
namespace Upyun;
33

4-
54
/**
65
* Class Signature
76
* @package Upyun
87
*/
9-
class Signature {
8+
class Signature
9+
{
1010
/**
1111
* 获取分块上传接口的签名
1212
*/
@@ -30,7 +30,8 @@ class Signature {
3030
*
3131
* @return array
3232
*/
33-
public static function getHeaderSign($bucketConfig, $method, $path, $contentMd5 = null) {
33+
public static function getHeaderSign($bucketConfig, $method, $path, $contentMd5 = null)
34+
{
3435
$gmtDate = gmdate('D, d M Y H:i:s \G\M\T');
3536

3637
$policy = null;
@@ -52,7 +53,8 @@ public static function getHeaderSign($bucketConfig, $method, $path, $contentMd5
5253
*
5354
* @return array
5455
*/
55-
public static function getPurgeSignHeader(Config $bucketConfig, $urlString) {
56+
public static function getPurgeSignHeader(Config $bucketConfig, $urlString)
57+
{
5658
$gmtDate = gmdate('D, d M Y H:i:s \G\M\T');
5759
$sign = md5("$urlString&{$bucketConfig->bucketName}&$gmtDate&{$bucketConfig->operatorPassword}");
5860
return array(
@@ -73,7 +75,8 @@ public static function getPurgeSignHeader(Config $bucketConfig, $urlString) {
7375
*
7476
* @return array
7577
*/
76-
public static function getBodySignature(Config $bucketConfig, $method, $uri, $date = null, $policy = null, $contentMd5 = null) {
78+
public static function getBodySignature(Config $bucketConfig, $method, $uri, $date = null, $policy = null, $contentMd5 = null)
79+
{
7780
$data = array(
7881
$method,
7982
$uri
@@ -93,7 +96,8 @@ public static function getBodySignature(Config $bucketConfig, $method, $uri, $da
9396
return 'UPYUN ' . $bucketConfig->operatorName . ':' . $signature;
9497
}
9598

96-
public static function getSignature(Config $bucketConfig, $data, $type, $tokenSecret = '') {
99+
public static function getSignature(Config $bucketConfig, $data, $type, $tokenSecret = '')
100+
{
97101
if (is_array($data)) {
98102
ksort($data);
99103
$string = '';

0 commit comments

Comments
 (0)