@@ -175,8 +175,8 @@ |
||
| 175 | 175 | } |
| 176 | 176 | if (count($ipv4) === 4) { |
| 177 | 177 | foreach ($ipv4 as $ipv4_part) { |
| 178 | - $value = (int) $ipv4_part; |
|
| 179 | - if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF) { |
|
| 178 | + $value = (int)$ipv4_part; |
|
| 179 | + if ((string)$value !== $ipv4_part || $value < 0 || $value > 0xFF) { |
|
| 180 | 180 | return false; |
| 181 | 181 | } |
| 182 | 182 | } |
@@ -106,8 +106,7 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | if ($ip_parts[1] !== '') { |
| 108 | 108 | return implode(':', $ip_parts); |
| 109 | - } |
|
| 110 | - else { |
|
| 109 | + } else { |
|
| 111 | 110 | return $ip_parts[0]; |
| 112 | 111 | } |
| 113 | 112 | } |
@@ -130,8 +129,7 @@ discard block |
||
| 130 | 129 | $ipv6_part = substr($ip, 0, $pos); |
| 131 | 130 | $ipv4_part = substr($ip, $pos + 1); |
| 132 | 131 | return array($ipv6_part, $ipv4_part); |
| 133 | - } |
|
| 134 | - else { |
|
| 132 | + } else { |
|
| 135 | 133 | return array($ip, ''); |
| 136 | 134 | } |
| 137 | 135 | } |
@@ -182,8 +180,7 @@ discard block |
||
| 182 | 180 | } |
| 183 | 181 | } |
| 184 | 182 | return true; |
| 185 | - } |
|
| 186 | - else { |
|
| 183 | + } else { |
|
| 187 | 184 | return false; |
| 188 | 185 | } |
| 189 | 186 | } |
@@ -112,8 +112,7 @@ |
||
| 112 | 112 | if (!$allow_redirects) { |
| 113 | 113 | throw new Requests_Exception('Redirection not allowed', 'response.no_redirects', $this); |
| 114 | 114 | } |
| 115 | - } |
|
| 116 | - elseif (!$this->success) { |
|
| 115 | + } elseif (!$this->success) { |
|
| 117 | 116 | $exception = Requests_Exception_HTTP::get_class($this->status_code); |
| 118 | 117 | throw new $exception(null, $this); |
| 119 | 118 | } |
@@ -31,5 +31,5 @@ |
||
| 31 | 31 | * @see Requests_Hooks::register |
| 32 | 32 | * @param Requests_Hooks $hooks Hook system |
| 33 | 33 | */ |
| 34 | - public function register(Requests_Hooks &$hooks); |
|
| 34 | + public function register(Requests_Hooks&$hooks); |
|
| 35 | 35 | } |
| 36 | 36 | \ No newline at end of file |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | * @see fsockopen_header |
| 54 | 54 | * @param Requests_Hooks $hooks Hook system |
| 55 | 55 | */ |
| 56 | - public function register(Requests_Hooks &$hooks) { |
|
| 56 | + public function register(Requests_Hooks&$hooks) { |
|
| 57 | 57 | $hooks->register('curl.before_send', array(&$this, 'curl_before_send')); |
| 58 | 58 | $hooks->register('fsockopen.after_headers', array(&$this, 'fsockopen_header')); |
| 59 | 59 | } |
@@ -277,7 +277,7 @@ |
||
| 277 | 277 | return null; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - $delta_seconds = (int) $value; |
|
| 280 | + $delta_seconds = (int)$value; |
|
| 281 | 281 | if ($delta_seconds <= 0) { |
| 282 | 282 | $expiry_time = 0; |
| 283 | 283 | } |
@@ -280,8 +280,7 @@ discard block |
||
| 280 | 280 | $delta_seconds = (int) $value; |
| 281 | 281 | if ($delta_seconds <= 0) { |
| 282 | 282 | $expiry_time = 0; |
| 283 | - } |
|
| 284 | - else { |
|
| 283 | + } else { |
|
| 285 | 284 | $expiry_time = $this->reference_time + $delta_seconds; |
| 286 | 285 | } |
| 287 | 286 | |
@@ -338,8 +337,7 @@ discard block |
||
| 338 | 337 | // Ignore non-associative attributes |
| 339 | 338 | if (is_numeric($key)) { |
| 340 | 339 | $parts[] = $value; |
| 341 | - } |
|
| 342 | - else { |
|
| 340 | + } else { |
|
| 343 | 341 | $parts[] = sprintf('%s=%s', $key, $value); |
| 344 | 342 | } |
| 345 | 343 | } |
@@ -385,8 +383,7 @@ discard block |
||
| 385 | 383 | |
| 386 | 384 | if (!empty($name)) { |
| 387 | 385 | $value = $string; |
| 388 | - } |
|
| 389 | - elseif (strpos($kvparts, '=') === false) { |
|
| 386 | + } elseif (strpos($kvparts, '=') === false) { |
|
| 390 | 387 | // Some sites might only have a value without the equals separator. |
| 391 | 388 | // Deviate from RFC 6265 and pretend it was actually a blank name |
| 392 | 389 | // (`=foo`) |
@@ -394,8 +391,7 @@ discard block |
||
| 394 | 391 | // https://bugzilla.mozilla.org/show_bug.cgi?id=169091 |
| 395 | 392 | $name = ''; |
| 396 | 393 | $value = $kvparts; |
| 397 | - } |
|
| 398 | - else { |
|
| 394 | + } else { |
|
| 399 | 395 | list($name, $value) = explode('=', $kvparts, 2); |
| 400 | 396 | } |
| 401 | 397 | $name = trim($name); |
@@ -409,8 +405,7 @@ discard block |
||
| 409 | 405 | if (strpos($part, '=') === false) { |
| 410 | 406 | $part_key = $part; |
| 411 | 407 | $part_value = true; |
| 412 | - } |
|
| 413 | - else { |
|
| 408 | + } else { |
|
| 414 | 409 | list($part_key, $part_value) = explode('=', $part, 2); |
| 415 | 410 | $part_value = trim($part_value); |
| 416 | 411 | } |
@@ -445,8 +440,7 @@ discard block |
||
| 445 | 440 | if (empty($parsed->attributes['domain']) && !empty($origin)) { |
| 446 | 441 | $parsed->attributes['domain'] = $origin->host; |
| 447 | 442 | $parsed->flags['host-only'] = true; |
| 448 | - } |
|
| 449 | - else { |
|
| 443 | + } else { |
|
| 450 | 444 | $parsed->flags['host-only'] = false; |
| 451 | 445 | } |
| 452 | 446 | |
@@ -460,14 +454,12 @@ discard block |
||
| 460 | 454 | // the uri-path is not a %x2F ("/") character, output |
| 461 | 455 | // %x2F ("/") and skip the remaining steps. |
| 462 | 456 | $path = '/'; |
| 463 | - } |
|
| 464 | - elseif (substr_count($path, '/') === 1) { |
|
| 457 | + } elseif (substr_count($path, '/') === 1) { |
|
| 465 | 458 | // If the uri-path contains no more than one %x2F ("/") |
| 466 | 459 | // character, output %x2F ("/") and skip the remaining |
| 467 | 460 | // step. |
| 468 | 461 | $path = '/'; |
| 469 | - } |
|
| 470 | - else { |
|
| 462 | + } else { |
|
| 471 | 463 | // Output the characters of the uri-path from the first |
| 472 | 464 | // character up to, but not including, the right-most |
| 473 | 465 | // %x2F ("/"). |
@@ -3,18 +3,18 @@ |
||
| 3 | 3 | |
| 4 | 4 | class GetPostDetails extends AbstractRequest { |
| 5 | 5 | |
| 6 | - function getApiEndPoint() |
|
| 7 | - { |
|
| 8 | - return '/v2/posts/' . $_GET['postID']; |
|
| 9 | - } |
|
| 10 | - function getPayload() |
|
| 11 | - { |
|
| 12 | - return array( |
|
| 13 | - ); |
|
| 14 | - } |
|
| 15 | - function getMethod() |
|
| 16 | - { |
|
| 17 | - return 'GET'; |
|
| 18 | - } |
|
| 6 | + function getApiEndPoint() |
|
| 7 | + { |
|
| 8 | + return '/v2/posts/' . $_GET['postID']; |
|
| 9 | + } |
|
| 10 | + function getPayload() |
|
| 11 | + { |
|
| 12 | + return array( |
|
| 13 | + ); |
|
| 14 | + } |
|
| 15 | + function getMethod() |
|
| 16 | + { |
|
| 17 | + return 'GET'; |
|
| 18 | + } |
|
| 19 | 19 | } |
| 20 | 20 | |
@@ -3,18 +3,18 @@ |
||
| 3 | 3 | |
| 4 | 4 | class Downvote extends AbstractRequest { |
| 5 | 5 | |
| 6 | - function getApiEndPoint() |
|
| 7 | - { |
|
| 8 | - return '/v2/posts/' . $_GET['postID'] . '/downvote'; |
|
| 9 | - } |
|
| 10 | - function getPayload() |
|
| 11 | - { |
|
| 12 | - return array( |
|
| 13 | - ); |
|
| 14 | - } |
|
| 15 | - function getMethod() |
|
| 16 | - { |
|
| 17 | - return 'PUT'; |
|
| 18 | - } |
|
| 6 | + function getApiEndPoint() |
|
| 7 | + { |
|
| 8 | + return '/v2/posts/' . $_GET['postID'] . '/downvote'; |
|
| 9 | + } |
|
| 10 | + function getPayload() |
|
| 11 | + { |
|
| 12 | + return array( |
|
| 13 | + ); |
|
| 14 | + } |
|
| 15 | + function getMethod() |
|
| 16 | + { |
|
| 17 | + return 'PUT'; |
|
| 18 | + } |
|
| 19 | 19 | } |
| 20 | 20 | |
@@ -3,37 +3,37 @@ |
||
| 3 | 3 | |
| 4 | 4 | class UpdateLocation extends AbstractRequest { |
| 5 | 5 | /** |
| 6 | - * @var Location |
|
| 7 | - */ |
|
| 8 | - public $location; |
|
| 9 | - /** |
|
| 10 | - * @return Location |
|
| 11 | - */ |
|
| 12 | - public function getLocation(): Location |
|
| 13 | - { |
|
| 14 | - return $this->location; |
|
| 15 | - } |
|
| 16 | - /** |
|
| 17 | - * @param Location $location |
|
| 18 | - */ |
|
| 19 | - public function setLocation(Location $location) |
|
| 20 | - { |
|
| 21 | - $this->location = $location; |
|
| 22 | - } |
|
| 6 | + * @var Location |
|
| 7 | + */ |
|
| 8 | + public $location; |
|
| 9 | + /** |
|
| 10 | + * @return Location |
|
| 11 | + */ |
|
| 12 | + public function getLocation(): Location |
|
| 13 | + { |
|
| 14 | + return $this->location; |
|
| 15 | + } |
|
| 16 | + /** |
|
| 17 | + * @param Location $location |
|
| 18 | + */ |
|
| 19 | + public function setLocation(Location $location) |
|
| 20 | + { |
|
| 21 | + $this->location = $location; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - function getApiEndPoint() |
|
| 25 | - { |
|
| 26 | - return '/v2/users/location'; |
|
| 27 | - } |
|
| 28 | - function getPayload() |
|
| 29 | - { |
|
| 30 | - return array( |
|
| 24 | + function getApiEndPoint() |
|
| 25 | + { |
|
| 26 | + return '/v2/users/location'; |
|
| 27 | + } |
|
| 28 | + function getPayload() |
|
| 29 | + { |
|
| 30 | + return array( |
|
| 31 | 31 | "location" => $this->getLocation()->toArray(), |
| 32 | - ); |
|
| 33 | - } |
|
| 34 | - function getMethod() |
|
| 35 | - { |
|
| 36 | - return 'PUT'; |
|
| 37 | - } |
|
| 32 | + ); |
|
| 33 | + } |
|
| 34 | + function getMethod() |
|
| 35 | + { |
|
| 36 | + return 'PUT'; |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | |
@@ -2,51 +2,51 @@ |
||
| 2 | 2 | |
| 3 | 3 | class Location{ |
| 4 | 4 | |
| 5 | - public $cityName; |
|
| 6 | - |
|
| 7 | - public $lat; |
|
| 8 | - |
|
| 9 | - public $lng; |
|
| 10 | - |
|
| 11 | - public function getCityName(): string |
|
| 12 | - { |
|
| 13 | - return $this->cityName; |
|
| 14 | - } |
|
| 15 | - |
|
| 16 | - public function setCityName(string $cityName) |
|
| 17 | - { |
|
| 18 | - $this->cityName = $cityName; |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - public function getLat(): string |
|
| 22 | - { |
|
| 23 | - return $this->lat; |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - public function setLat(string $lat) |
|
| 27 | - { |
|
| 28 | - $this->lat = $lat; |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - public function getLng(): string |
|
| 32 | - { |
|
| 33 | - return $this->lng; |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - public function setLng(string $lng) |
|
| 37 | - { |
|
| 38 | - $this->lng = $lng; |
|
| 39 | - } |
|
| 40 | - public function toArray(){ |
|
| 41 | - return array( |
|
| 42 | - "city" => $this->getCityName(), |
|
| 43 | - "country" => 'DE', |
|
| 44 | - "loc_accuracy" => '0.0', |
|
| 45 | - "loc_coordinates" => array( |
|
| 46 | - "lat" => $this->getLat(), |
|
| 47 | - "lng" => $this->getLng(), |
|
| 48 | - ), |
|
| 49 | - "name" => $this->getCityName() |
|
| 50 | - ); |
|
| 51 | - } |
|
| 5 | + public $cityName; |
|
| 6 | + |
|
| 7 | + public $lat; |
|
| 8 | + |
|
| 9 | + public $lng; |
|
| 10 | + |
|
| 11 | + public function getCityName(): string |
|
| 12 | + { |
|
| 13 | + return $this->cityName; |
|
| 14 | + } |
|
| 15 | + |
|
| 16 | + public function setCityName(string $cityName) |
|
| 17 | + { |
|
| 18 | + $this->cityName = $cityName; |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + public function getLat(): string |
|
| 22 | + { |
|
| 23 | + return $this->lat; |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + public function setLat(string $lat) |
|
| 27 | + { |
|
| 28 | + $this->lat = $lat; |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + public function getLng(): string |
|
| 32 | + { |
|
| 33 | + return $this->lng; |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + public function setLng(string $lng) |
|
| 37 | + { |
|
| 38 | + $this->lng = $lng; |
|
| 39 | + } |
|
| 40 | + public function toArray(){ |
|
| 41 | + return array( |
|
| 42 | + "city" => $this->getCityName(), |
|
| 43 | + "country" => 'DE', |
|
| 44 | + "loc_accuracy" => '0.0', |
|
| 45 | + "loc_coordinates" => array( |
|
| 46 | + "lat" => $this->getLat(), |
|
| 47 | + "lng" => $this->getLng(), |
|
| 48 | + ), |
|
| 49 | + "name" => $this->getCityName() |
|
| 50 | + ); |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class Location{ |
|
| 3 | +class Location { |
|
| 4 | 4 | |
| 5 | 5 | public $cityName; |
| 6 | 6 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | $this->lng = $lng; |
| 39 | 39 | } |
| 40 | - public function toArray(){ |
|
| 40 | + public function toArray() { |
|
| 41 | 41 | return array( |
| 42 | 42 | "city" => $this->getCityName(), |
| 43 | 43 | "country" => 'DE', |