@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | * @see Sigleton Pattern |
| 30 | 30 | * |
| 31 | 31 | */ |
| 32 | - private function __construct ( $config = [] ) |
|
| 32 | + private function __construct($config = []) |
|
| 33 | 33 | { |
| 34 | - parent::__construct( $config ); |
|
| 34 | + parent::__construct($config); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -46,11 +46,11 @@ discard block |
||
| 46 | 46 | public static function url($uri = null) |
| 47 | 47 | { |
| 48 | 48 | // change API URI |
| 49 | - if($uri !== null){ |
|
| 49 | + if ($uri !== null) { |
|
| 50 | 50 | self::$url_reference = $uri; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if(self::$instance === null){ |
|
| 53 | + if (self::$instance === null) { |
|
| 54 | 54 | self::$instance = new self; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -74,15 +74,15 @@ discard block |
||
| 74 | 74 | $redirects_count = 0; |
| 75 | 75 | |
| 76 | 76 | // base URI reference |
| 77 | - if (!self::$url_reference){ |
|
| 77 | + if (!self::$url_reference) { |
|
| 78 | 78 | throw new CittaException('URI Reference Error'); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // consult URI |
| 82 | - if (is_array($uri)){ |
|
| 82 | + if (is_array($uri)) { |
|
| 83 | 83 | $curl->get(self::$url_reference.\yii\helpers\Url::to($uri)); |
| 84 | 84 | |
| 85 | - } else if (is_string($uri)){ |
|
| 85 | + } else if (is_string($uri)) { |
|
| 86 | 86 | $curl->get(self::$url_reference."/{$uri}"); |
| 87 | 87 | |
| 88 | 88 | } else { |
@@ -91,20 +91,20 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | |
| 93 | 93 | // redirect URI |
| 94 | - while (300 <= $curl->http_status_code && $curl->http_status_code < 400){ |
|
| 94 | + while (300 <= $curl->http_status_code && $curl->http_status_code < 400) { |
|
| 95 | 95 | // probably loop |
| 96 | - if (++$redirects_count > 10){ |
|
| 96 | + if (++$redirects_count > 10) { |
|
| 97 | 97 | throw new CittaException('Too many redirects'); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | foreach ($curl->response_headers as $header) { |
| 101 | 101 | // ignore header |
| 102 | - if (strpos($header, 'Location:') === false){ |
|
| 102 | + if (strpos($header, 'Location:') === false) { |
|
| 103 | 103 | continue; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // try new uri |
| 107 | - $curl->get(strtr($header,[ |
|
| 107 | + $curl->get(strtr($header, [ |
|
| 108 | 108 | 'Location: ' => '', |
| 109 | 109 | 'location: ' => '', |
| 110 | 110 | 'Location:' => '', |
@@ -115,12 +115,12 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | // resquest error |
| 118 | - if ($curl->error && $curl->http_status_code){ |
|
| 118 | + if ($curl->error && $curl->http_status_code) { |
|
| 119 | 119 | throw new CittaException("HTTP Status {$curl->http_status_code} Error"); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | // curl error |
| 123 | - if ($curl->error){ |
|
| 123 | + if ($curl->error) { |
|
| 124 | 124 | throw new CittaException($curl->error_message); |
| 125 | 125 | } |
| 126 | 126 | |