@@ -4,11 +4,11 @@ |
||
4 | 4 | |
5 | 5 | class Response { |
6 | 6 | |
7 | - /** |
|
8 | - * status of the server response - fail is not nessisary a fail in this case |
|
9 | - * |
|
10 | - * @var string |
|
11 | - */ |
|
7 | + /** |
|
8 | + * status of the server response - fail is not nessisary a fail in this case |
|
9 | + * |
|
10 | + * @var string |
|
11 | + */ |
|
12 | 12 | public $statusCode; |
13 | 13 | /** |
14 | 14 | * status code of the server response |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | public $message; |
26 | 26 | |
27 | 27 | |
28 | - public function __construct($body, $format){ |
|
28 | + public function __construct($body, $format) { |
|
29 | 29 | switch ($format) { |
30 | 30 | case 'xml': |
31 | 31 | libxml_use_internal_errors(true); |
@@ -44,19 +44,19 @@ discard block |
||
44 | 44 | $this->parseResponseBody($res); |
45 | 45 | } |
46 | 46 | |
47 | - protected function parseResponseBody($body){ |
|
48 | - if(empty($body)){ |
|
47 | + protected function parseResponseBody($body) { |
|
48 | + if (empty($body)) { |
|
49 | 49 | throw new \Exception("No response recieved"); |
50 | 50 | } |
51 | 51 | |
52 | - if(\is_string($body) ){ |
|
52 | + if (\is_string($body)) { |
|
53 | 53 | $this->status = 'success'; |
54 | 54 | $this->statusCode = '200'; |
55 | 55 | $this->shorturl = $url; |
56 | 56 | return; |
57 | 57 | } |
58 | 58 | |
59 | - foreach((array)$body as $key => $value){ |
|
59 | + foreach ((array) $body as $key => $value) { |
|
60 | 60 | $this->{$key} = $value; |
61 | 61 | } |
62 | 62 |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | 'filter' => $filter, |
167 | 167 | 'format' => $this->setFormat($format) |
168 | 168 | ]; |
169 | - if (! empty($limit)) { |
|
169 | + if (!empty($limit)) { |
|
170 | 170 | $params = array_merge($params, ['limit' => $limit]); |
171 | 171 | } |
172 | 172 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $form_params = array_merge($request, $this->authParam); |
206 | 206 | |
207 | 207 | $result = $this->client->request('POST', 'yourls-api.php', ['form_params' => $form_params]); |
208 | - if(!$result || '200' != $result->getStatusCode()) { |
|
208 | + if (!$result || '200' != $result->getStatusCode()) { |
|
209 | 209 | throw new \Exception('Failed to process request'); |
210 | 210 | } |
211 | 211 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @return string |
236 | 236 | */ |
237 | - protected function setFormat(string $format = NULL){ |
|
238 | - return empty($format) || !in_array($format, $this->formats) ? $this->format: $format; |
|
237 | + protected function setFormat(string $format = NULL) { |
|
238 | + return empty($format) || !in_array($format, $this->formats) ? $this->format : $format; |
|
239 | 239 | } |
240 | 240 | } |