@@ -51,8 +51,7 @@ discard block |
||
| 51 | 51 | * @class HttpCookie |
| 52 | 52 | * @package Platine\Http\Client |
| 53 | 53 | */ |
| 54 | -class HttpCookie |
|
| 55 | -{ |
|
| 54 | +class HttpCookie { |
|
| 56 | 55 | /** |
| 57 | 56 | * The name of cookie |
| 58 | 57 | * @var string |
@@ -112,8 +111,7 @@ discard block |
||
| 112 | 111 | * Create new instance |
| 113 | 112 | * @param string $cookieString |
| 114 | 113 | */ |
| 115 | - public function __construct(string $cookieString) |
|
| 116 | - { |
|
| 114 | + public function __construct(string $cookieString) { |
|
| 117 | 115 | $parts = array_map('trim', explode(';', $cookieString)); |
| 118 | 116 | foreach ($parts as $partStr) { |
| 119 | 117 | $part = array_map('trim', explode('=', $partStr)); |
@@ -51,8 +51,7 @@ |
||
| 51 | 51 | * @class HttpMethod |
| 52 | 52 | * @package Platine\Http\Client |
| 53 | 53 | */ |
| 54 | -class HttpMethod |
|
| 55 | -{ |
|
| 54 | +class HttpMethod { |
|
| 56 | 55 | public const HEAD = 'HEAD'; |
| 57 | 56 | public const GET = 'GET'; |
| 58 | 57 | public const PUT = 'PUT'; |
@@ -57,8 +57,7 @@ |
||
| 57 | 57 | * @class HttpStatus |
| 58 | 58 | * @package Platine\Http\Client |
| 59 | 59 | */ |
| 60 | -class HttpStatus |
|
| 61 | -{ |
|
| 60 | +class HttpStatus { |
|
| 62 | 61 | // Informational 1xx: |
| 63 | 62 | public const INFORMATIONAL = 100; |
| 64 | 63 | public const CONTINUE = 100; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | // Informational 1xx: |
| 63 | 63 | public const INFORMATIONAL = 100; |
| 64 | - public const CONTINUE = 100; |
|
| 64 | + public const continue = 100; |
|
| 65 | 65 | public const SWITCHING_PROTOCOLS = 101; |
| 66 | 66 | |
| 67 | 67 | // Successful 2xx: |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | public const SERVER_ERROR_END = 600; |
| 118 | 118 | |
| 119 | 119 | public const REASON_PHRASES = [ |
| 120 | - self::CONTINUE => 'Continue', |
|
| 120 | + self::continue => 'Continue', |
|
| 121 | 121 | self::SWITCHING_PROTOCOLS => 'Switching Protocols', |
| 122 | 122 | |
| 123 | 123 | self::OK => 'OK', |
@@ -270,8 +270,8 @@ |
||
| 270 | 270 | */ |
| 271 | 271 | public function contentType(string $contentType): self |
| 272 | 272 | { |
| 273 | - // If this is a multipart request and boundary was not defined, |
|
| 274 | - // we define a boundary as this is required for multipart requests. |
|
| 273 | + // If this is a multipart request and boundary was not defined, |
|
| 274 | + // we define a boundary as this is required for multipart requests. |
|
| 275 | 275 | if (stripos($contentType, 'multipart/') !== false) { |
| 276 | 276 | if (stripos($contentType, 'boundary') === false) { |
| 277 | 277 | $contentType .= sprintf('; boundary="%s"', uniqid((string) time())); |
@@ -55,8 +55,7 @@ discard block |
||
| 55 | 55 | * @class HttpClient |
| 56 | 56 | * @package Platine\Http\Client |
| 57 | 57 | */ |
| 58 | -class HttpClient |
|
| 59 | -{ |
|
| 58 | +class HttpClient { |
|
| 60 | 59 | /** |
| 61 | 60 | * The base URL |
| 62 | 61 | * @var string |
@@ -109,8 +108,7 @@ discard block |
||
| 109 | 108 | * Create new instance |
| 110 | 109 | * @param string $baseUrl |
| 111 | 110 | */ |
| 112 | - public function __construct(string $baseUrl = '') |
|
| 113 | - { |
|
| 111 | + public function __construct(string $baseUrl = '') { |
|
| 114 | 112 | $this->baseUrl = $baseUrl; |
| 115 | 113 | } |
| 116 | 114 | |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | protected function send(CurlHandle $ch): HttpResponse |
| 552 | 552 | { |
| 553 | 553 | $responseHeaders = []; |
| 554 | - curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$responseHeaders) { |
|
| 554 | + curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($curl, $header) use (&$responseHeaders) { |
|
| 555 | 555 | if (strpos($header, ':') !== false) { |
| 556 | 556 | list($name, $value) = explode(':', $header); |
| 557 | 557 | if (array_key_exists($name, $responseHeaders) === false) { |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | * @param array<mixed>|object|null $body the request body |
| 681 | 681 | * @return void |
| 682 | 682 | */ |
| 683 | - protected function processBody(CurlHandle $ch, array|object|null $body = null): void |
|
| 683 | + protected function processBody(CurlHandle $ch, array | object | null $body = null): void |
|
| 684 | 684 | { |
| 685 | 685 | if ($body === null) { |
| 686 | 686 | return; |
@@ -251,7 +251,7 @@ |
||
| 251 | 251 | bool $assoc = false, |
| 252 | 252 | int $depth = 512, |
| 253 | 253 | int $options = 0 |
| 254 | - ): array|object { |
|
| 254 | + ): array | object { |
|
| 255 | 255 | return Json::decode($this->content, $assoc, $depth, $options); |
| 256 | 256 | } |
| 257 | 257 | |
@@ -54,8 +54,7 @@ |
||
| 54 | 54 | * @class HttpResponse |
| 55 | 55 | * @package Platine\Http\Client |
| 56 | 56 | */ |
| 57 | -class HttpResponse |
|
| 58 | -{ |
|
| 57 | +class HttpResponse { |
|
| 59 | 58 | /** |
| 60 | 59 | * The request URL |
| 61 | 60 | * @var string |
@@ -39,6 +39,5 @@ |
||
| 39 | 39 | * @class HttpClientException |
| 40 | 40 | * @package Platine\Http\Client\Exception |
| 41 | 41 | */ |
| 42 | -class HttpClientException extends Exception |
|
| 43 | -{ |
|
| 42 | +class HttpClientException extends Exception { |
|
| 44 | 43 | } |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | */ |
| 81 | 81 | public function __construct( |
| 82 | 82 | string $method = 'GET', |
| 83 | - UriInterface|string|null $uri = null |
|
| 83 | + UriInterface | string | null $uri = null |
|
| 84 | 84 | ) { |
| 85 | 85 | $this->method = $this->filterMethod($method); |
| 86 | 86 | if ($uri === null) { |
@@ -53,8 +53,7 @@ |
||
| 53 | 53 | * @class Request |
| 54 | 54 | * @package Platine\Http |
| 55 | 55 | */ |
| 56 | -class Request extends Message implements RequestInterface |
|
| 57 | -{ |
|
| 56 | +class Request extends Message implements RequestInterface { |
|
| 58 | 57 | /** |
| 59 | 58 | * The request target |
| 60 | 59 | * @var string |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | |
| 517 | 517 | return (string) preg_replace_callback( |
| 518 | 518 | '/(?:[^a-zA-Z0-9\-._~!$&\'()*+,;=:@\/%]++|%(?![a-fA-F0-9]{2}))/', |
| 519 | - function ($matches) { |
|
| 519 | + function($matches) { |
|
| 520 | 520 | return rawurlencode($matches[0]); |
| 521 | 521 | }, |
| 522 | 522 | $path |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | |
| 548 | 548 | return (string) preg_replace_callback( |
| 549 | 549 | '/(?:[^a-zA-Z0-9\-._~!$&\'()*+,;=:@\/?%]++|%(?![a-fA-F0-9]{2}))/', |
| 550 | - function ($matches) { |
|
| 550 | + function($matches) { |
|
| 551 | 551 | return rawurlencode($matches[0]); |
| 552 | 552 | }, |
| 553 | 553 | $query |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | if ($fragment !== '') { |
| 568 | 568 | return (string) preg_replace_callback( |
| 569 | 569 | '/(?:[^a-zA-Z0-9\-._~!$&\'()*+,;=:@\/?%]++|%(?![a-fA-F0-9]{2}))/', |
| 570 | - function ($matches) { |
|
| 570 | + function($matches) { |
|
| 571 | 571 | return rawurlencode($matches[0]); |
| 572 | 572 | }, |
| 573 | 573 | $fragment |
@@ -53,8 +53,7 @@ discard block |
||
| 53 | 53 | * @class Uri |
| 54 | 54 | * @package Platine\Http |
| 55 | 55 | */ |
| 56 | -class Uri implements UriInterface |
|
| 57 | -{ |
|
| 56 | +class Uri implements UriInterface { |
|
| 58 | 57 | /** |
| 59 | 58 | * The Uri scheme |
| 60 | 59 | * @var string |
@@ -101,8 +100,7 @@ discard block |
||
| 101 | 100 | * Create new Uri instance |
| 102 | 101 | * @param string $uri |
| 103 | 102 | */ |
| 104 | - public function __construct(string $uri = '') |
|
| 105 | - { |
|
| 103 | + public function __construct(string $uri = '') { |
|
| 106 | 104 | if ($uri !== '') { |
| 107 | 105 | $parts = parse_url($uri); |
| 108 | 106 | |
@@ -53,8 +53,7 @@ discard block |
||
| 53 | 53 | * @class Response |
| 54 | 54 | * @package Platine\Http |
| 55 | 55 | */ |
| 56 | -class Response extends Message implements ResponseInterface |
|
| 57 | -{ |
|
| 56 | +class Response extends Message implements ResponseInterface { |
|
| 58 | 57 | /** |
| 59 | 58 | * The reason phrases. |
| 60 | 59 | */ |
@@ -155,8 +154,7 @@ discard block |
||
| 155 | 154 | * @param int $statusCode |
| 156 | 155 | * @param string $reasonPhrase |
| 157 | 156 | */ |
| 158 | - public function __construct(int $statusCode = 200, string $reasonPhrase = '') |
|
| 159 | - { |
|
| 157 | + public function __construct(int $statusCode = 200, string $reasonPhrase = '') { |
|
| 160 | 158 | $this->statusCode = $this->filterStatusCode($statusCode); |
| 161 | 159 | if ($reasonPhrase === '') { |
| 162 | 160 | $reasonPhrase = static::REASON_PHRASES[$this->statusCode] ?? ''; |