Skip to content

Commit 3dce063

Browse files
committed
fmt code
1 parent 4c99d21 commit 3dce063

File tree

3 files changed

+15
-25
lines changed

3 files changed

+15
-25
lines changed

src/Qiniu/Auth.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ public function uploadToken(
9090
$args['scope'] = $scope;
9191
$args['deadline'] = $deadline;
9292

93-
if ($zone === null)
94-
{
93+
if ($zone === null) {
9594
$zone = new Zone();
9695
}
9796
$args['upHosts'] = $zone->getUpHosts($this->accessKey, $bucket);

src/Qiniu/Storage/BucketManager.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ final class BucketManager
2020
public function __construct(Auth $auth, Zone $zone = null)
2121
{
2222
$this->auth = $auth;
23-
if ($zone === null)
24-
{
23+
if ($zone === null) {
2524
$this->zone = new Zone();
2625
}
2726
}
@@ -216,7 +215,7 @@ public function fetch($url, $bucket, $key = null)
216215
$ak = $this->auth->getAccessKey();
217216
$ioHost = $this->zone->getIoHost($ak, $bucket);
218217

219-
$url = $ioPost . $path;
218+
$url = $ioHost . $path;
220219
return $this->post($url, null);
221220
}
222221

@@ -237,7 +236,7 @@ public function prefetch($bucket, $key)
237236
$ak = $this->auth->getAccessKey();
238237
$ioHost = $this->zone->getIoHost($ak, $bucket);
239238

240-
$url = $ioPost . $path;
239+
$url = $ioHost . $path;
241240
list(, $error) = $this->post($url, null);
242241
return $error;
243242
}

src/Qiniu/Zone.php

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ final class Zone
1616
public function __construct($scheme = null)
1717
{
1818
$this->hostCache = array();
19-
if ($scheme != null)
20-
{
19+
if ($scheme != null) {
2120
$this->scheme = $scheme;
2221
}
2322
}
@@ -39,15 +38,13 @@ public function getBackupUpHostByToken($uptoken)
3938
public function getIoHost($ak, $bucket)
4039
{
4140
list($bucketHosts, ) = $this->getBucketHosts($ak, $bucket);
42-
$ioHost = $bucketHosts['ioHost'];
43-
return $upHost;
41+
return $bucketHosts['ioHost'][0];
4442
}
4543

4644
public function getUpHosts($ak, $bucket)
4745
{
4846
list($bucketHosts, $err) = $this->getBucketHosts($ak, $bucket);
49-
if ($err !== null)
50-
{
47+
if ($err !== null) {
5148
return array(null, $err);
5249
}
5350

@@ -58,8 +55,7 @@ public function getUpHosts($ak, $bucket)
5855
private function unmarshalUpToken($uptoken)
5956
{
6057
$token = split(':', $uptoken);
61-
if (count($token) !== 3)
62-
{
58+
if (count($token) !== 3) {
6359
throw new \Exception("Invalid Uptoken", 1);
6460
}
6561

@@ -68,8 +64,7 @@ private function unmarshalUpToken($uptoken)
6864
$policy = json_decode($policy, true);
6965

7066
$bucket = $policy['scope'];
71-
if (strpos($bucket, ':'))
72-
{
67+
if (strpos($bucket, ':')) {
7368
$bucket = split(':', $bucket)[0];
7469
}
7570

@@ -81,19 +76,16 @@ public function getBucketHosts($ak, $bucket)
8176
$key = $ak . $bucket;
8277

8378
$exist = false;
84-
if (count($this->hostCache) > 0)
85-
{
79+
if (count($this->hostCache) > 0) {
8680
$exist = array_key_exists($key, $this->hostCache) && $this->hostCache[$key]['deadline'] > time();
8781
}
8882

89-
if ($exist)
90-
{
83+
if ($exist) {
9184
return $this->hostCache[$key];
9285
}
9386

9487
list($hosts, $err) = $this->bucketHosts($ak, $bucket);
95-
if ($err !== null)
96-
{
88+
if ($err !== null) {
9789
return array(null , $err);
9890
}
9991

@@ -121,10 +113,10 @@ public function getBucketHosts($ak, $bucket)
121113
* }
122114
* }
123115
**/
124-
private function bucketHosts($ak, $bucket)
116+
private function bucketHosts($ak, $bucket)
125117
{
126-
$path = '/v1/query' . "?ak=$ak&bucket=$bucket";
127-
$ret = Client::Get(Config::UC_HOST . $path);
118+
$url = Config::UC_HOST . '/v1/query' . "?ak=$ak&bucket=$bucket";
119+
$ret = Client::Get($url);
128120
if (!$ret->ok()) {
129121
return array(null, new Error($url, $ret));
130122
}

0 commit comments

Comments
 (0)