@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @see Sigleton Pattern |
28 | 28 | */ |
29 | - private function __construct () |
|
29 | + private function __construct() |
|
30 | 30 | { |
31 | 31 | |
32 | 32 | } |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | public static function url($uri = null) |
44 | 44 | { |
45 | 45 | // change API URI |
46 | - if($uri !== null){ |
|
46 | + if ($uri !== null) { |
|
47 | 47 | self::$url_reference = $uri; |
48 | 48 | } |
49 | 49 | |
50 | 50 | // create object |
51 | - if(self::$instance === null){ |
|
51 | + if (self::$instance === null) { |
|
52 | 52 | self::$instance = new self; |
53 | 53 | } |
54 | 54 | |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | $redirects_count = 0; |
71 | 71 | |
72 | 72 | // base URI reference |
73 | - if (!self::$url_reference){ |
|
73 | + if (!self::$url_reference) { |
|
74 | 74 | throw new CittaException('URI Reference Error'); |
75 | 75 | } |
76 | 76 | |
77 | 77 | // consult URI |
78 | - if (is_array($uri)){ |
|
78 | + if (is_array($uri)) { |
|
79 | 79 | $curl->get(self::$url_reference.\yii\helpers\Url::to($uri)); |
80 | 80 | |
81 | - } else if (is_string($uri)){ |
|
81 | + } else if (is_string($uri)) { |
|
82 | 82 | $curl->get(self::$url_reference."/{$uri}"); |
83 | 83 | |
84 | 84 | } else { |
@@ -86,20 +86,20 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | // redirect URI |
89 | - while (300 <= $curl->http_status_code && $curl->http_status_code < 400){ |
|
89 | + while (300 <= $curl->http_status_code && $curl->http_status_code < 400) { |
|
90 | 90 | // probably loop |
91 | - if (++$redirects_count > 10){ |
|
91 | + if (++$redirects_count > 10) { |
|
92 | 92 | throw new CittaException('Too many redirects'); |
93 | 93 | } |
94 | 94 | |
95 | 95 | foreach ($curl->response_headers as $header) { |
96 | 96 | // ignore header |
97 | - if (strpos($header, 'Location:') === false){ |
|
97 | + if (strpos($header, 'Location:') === false) { |
|
98 | 98 | continue; |
99 | 99 | } |
100 | 100 | |
101 | 101 | // try new uri |
102 | - $curl->get(strtr($header,[ |
|
102 | + $curl->get(strtr($header, [ |
|
103 | 103 | 'Location: ' => '', |
104 | 104 | 'location: ' => '', |
105 | 105 | 'Location:' => '', |
@@ -130,12 +130,12 @@ discard block |
||
130 | 130 | $api = self::run($uri); |
131 | 131 | |
132 | 132 | // resquest error |
133 | - if ($api->error && $api->http_status_code){ |
|
133 | + if ($api->error && $api->http_status_code) { |
|
134 | 134 | throw new CittaException("HTTP Status {$api->http_status_code} Error"); |
135 | 135 | } |
136 | 136 | |
137 | 137 | // curl error |
138 | - if ($api->error){ |
|
138 | + if ($api->error) { |
|
139 | 139 | throw new CittaException($api->error_message); |
140 | 140 | } |
141 | 141 |