@@ -27,35 +27,35 @@ |
||
| 27 | 27 | class StreamFactory implements StreamFactoryInterface |
| 28 | 28 | { |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * {@inheritdoc} |
|
| 32 | - */ |
|
| 33 | - public function createStream(string $content = ''): StreamInterface |
|
| 34 | - { |
|
| 35 | - $stream = new PhpTempStream(); |
|
| 36 | - if ($content === '') { |
|
| 37 | - return $stream; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - $stream->write($content); |
|
| 41 | - $stream->rewind(); |
|
| 42 | - |
|
| 43 | - return $stream; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * {@inheritdoc} |
|
| 48 | - */ |
|
| 49 | - public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface |
|
| 50 | - { |
|
| 51 | - return new FileStream($filename, $mode); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * {@inheritdoc} |
|
| 56 | - */ |
|
| 57 | - public function createStreamFromResource($resource): StreamInterface |
|
| 58 | - { |
|
| 59 | - return new Stream($resource); |
|
| 60 | - } |
|
| 30 | + /** |
|
| 31 | + * {@inheritdoc} |
|
| 32 | + */ |
|
| 33 | + public function createStream(string $content = ''): StreamInterface |
|
| 34 | + { |
|
| 35 | + $stream = new PhpTempStream(); |
|
| 36 | + if ($content === '') { |
|
| 37 | + return $stream; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + $stream->write($content); |
|
| 41 | + $stream->rewind(); |
|
| 42 | + |
|
| 43 | + return $stream; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * {@inheritdoc} |
|
| 48 | + */ |
|
| 49 | + public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface |
|
| 50 | + { |
|
| 51 | + return new FileStream($filename, $mode); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * {@inheritdoc} |
|
| 56 | + */ |
|
| 57 | + public function createStreamFromResource($resource): StreamInterface |
|
| 58 | + { |
|
| 59 | + return new Stream($resource); |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -25,11 +25,11 @@ |
||
| 25 | 25 | class UriFactory implements UriFactoryInterface |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * {@inheritdoc} |
|
| 30 | - */ |
|
| 31 | - public function createUri(string $uri = ''): UriInterface |
|
| 32 | - { |
|
| 33 | - return new Uri($uri); |
|
| 34 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritdoc} |
|
| 30 | + */ |
|
| 31 | + public function createUri(string $uri = ''): UriInterface |
|
| 32 | + { |
|
| 33 | + return new Uri($uri); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -25,11 +25,11 @@ |
||
| 25 | 25 | class RequestFactory implements RequestFactoryInterface |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * {@inheritdoc} |
|
| 30 | - */ |
|
| 31 | - public function createRequest(string $method, $uri): RequestInterface |
|
| 32 | - { |
|
| 33 | - return new Request($method, $uri); |
|
| 34 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritdoc} |
|
| 30 | + */ |
|
| 31 | + public function createRequest(string $method, $uri): RequestInterface |
|
| 32 | + { |
|
| 33 | + return new Request($method, $uri); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -17,10 +17,10 @@ |
||
| 17 | 17 | interface ComponentInterface |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Gets the component value |
|
| 22 | - * |
|
| 23 | - * @return mixed |
|
| 24 | - */ |
|
| 25 | - public function getValue(); |
|
| 20 | + /** |
|
| 21 | + * Gets the component value |
|
| 22 | + * |
|
| 23 | + * @return mixed |
|
| 24 | + */ |
|
| 25 | + public function getValue(); |
|
| 26 | 26 | } |
@@ -29,48 +29,48 @@ |
||
| 29 | 29 | final class Port implements ComponentInterface |
| 30 | 30 | { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * The component value |
|
| 34 | - * |
|
| 35 | - * @var int|null |
|
| 36 | - */ |
|
| 37 | - private ?int $value = null; |
|
| 32 | + /** |
|
| 33 | + * The component value |
|
| 34 | + * |
|
| 35 | + * @var int|null |
|
| 36 | + */ |
|
| 37 | + private ?int $value = null; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Constructor of the class |
|
| 41 | - * |
|
| 42 | - * @param mixed $value |
|
| 43 | - * |
|
| 44 | - * @throws InvalidUriComponentException |
|
| 45 | - * If the component isn't valid. |
|
| 46 | - */ |
|
| 47 | - public function __construct($value) |
|
| 48 | - { |
|
| 49 | - $min = 1; |
|
| 50 | - $max = (2 ** 16) - 1; |
|
| 39 | + /** |
|
| 40 | + * Constructor of the class |
|
| 41 | + * |
|
| 42 | + * @param mixed $value |
|
| 43 | + * |
|
| 44 | + * @throws InvalidUriComponentException |
|
| 45 | + * If the component isn't valid. |
|
| 46 | + */ |
|
| 47 | + public function __construct($value) |
|
| 48 | + { |
|
| 49 | + $min = 1; |
|
| 50 | + $max = (2 ** 16) - 1; |
|
| 51 | 51 | |
| 52 | - if ($value === null) { |
|
| 53 | - return; |
|
| 54 | - } |
|
| 52 | + if ($value === null) { |
|
| 53 | + return; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - if (!is_int($value)) { |
|
| 57 | - throw new InvalidUriComponentException('URI component "port" must be an integer'); |
|
| 58 | - } |
|
| 56 | + if (!is_int($value)) { |
|
| 57 | + throw new InvalidUriComponentException('URI component "port" must be an integer'); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - if (!($value >= $min && $value <= $max)) { |
|
| 61 | - throw new InvalidUriComponentException('Invalid URI component "port"'); |
|
| 62 | - } |
|
| 60 | + if (!($value >= $min && $value <= $max)) { |
|
| 61 | + throw new InvalidUriComponentException('Invalid URI component "port"'); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - $this->value = $value; |
|
| 65 | - } |
|
| 64 | + $this->value = $value; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * {@inheritdoc} |
|
| 69 | - * |
|
| 70 | - * @return int|null |
|
| 71 | - */ |
|
| 72 | - public function getValue(): ?int |
|
| 73 | - { |
|
| 74 | - return $this->value; |
|
| 75 | - } |
|
| 67 | + /** |
|
| 68 | + * {@inheritdoc} |
|
| 69 | + * |
|
| 70 | + * @return int|null |
|
| 71 | + */ |
|
| 72 | + public function getValue(): ?int |
|
| 73 | + { |
|
| 74 | + return $this->value; |
|
| 75 | + } |
|
| 76 | 76 | } |
@@ -25,11 +25,11 @@ |
||
| 25 | 25 | class ResponseFactory implements ResponseFactoryInterface |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * {@inheritdoc} |
|
| 30 | - */ |
|
| 31 | - public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface |
|
| 32 | - { |
|
| 33 | - return new Response($code, $reasonPhrase); |
|
| 34 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritdoc} |
|
| 30 | + */ |
|
| 31 | + public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface |
|
| 32 | + { |
|
| 33 | + return new Response($code, $reasonPhrase); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -31,22 +31,22 @@ |
||
| 31 | 31 | class UploadedFileFactory implements UploadedFileFactoryInterface |
| 32 | 32 | { |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * {@inheritdoc} |
|
| 36 | - */ |
|
| 37 | - public function createUploadedFile( |
|
| 38 | - StreamInterface $stream, |
|
| 39 | - ?int $size = null, |
|
| 40 | - int $error = UPLOAD_ERR_OK, |
|
| 41 | - ?string $clientFilename = null, |
|
| 42 | - ?string $clientMediaType = null |
|
| 43 | - ): UploadedFileInterface { |
|
| 44 | - return new UploadedFile( |
|
| 45 | - $stream, |
|
| 46 | - $size, |
|
| 47 | - $error, |
|
| 48 | - $clientFilename, |
|
| 49 | - $clientMediaType |
|
| 50 | - ); |
|
| 51 | - } |
|
| 34 | + /** |
|
| 35 | + * {@inheritdoc} |
|
| 36 | + */ |
|
| 37 | + public function createUploadedFile( |
|
| 38 | + StreamInterface $stream, |
|
| 39 | + ?int $size = null, |
|
| 40 | + int $error = UPLOAD_ERR_OK, |
|
| 41 | + ?string $clientFilename = null, |
|
| 42 | + ?string $clientMediaType = null |
|
| 43 | + ): UploadedFileInterface { |
|
| 44 | + return new UploadedFile( |
|
| 45 | + $stream, |
|
| 46 | + $size, |
|
| 47 | + $error, |
|
| 48 | + $clientFilename, |
|
| 49 | + $clientMediaType |
|
| 50 | + ); |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -32,29 +32,29 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | function server_request_headers(?array $serverParams = null): array |
| 34 | 34 | { |
| 35 | - $serverParams ??= $_SERVER; |
|
| 35 | + $serverParams ??= $_SERVER; |
|
| 36 | 36 | |
| 37 | - // https://datatracker.ietf.org/doc/html/rfc3875#section-4.1.2 |
|
| 38 | - if (!isset($serverParams['HTTP_CONTENT_LENGTH']) && isset($serverParams['CONTENT_LENGTH'])) { |
|
| 39 | - $serverParams['HTTP_CONTENT_LENGTH'] = $serverParams['CONTENT_LENGTH']; |
|
| 40 | - } |
|
| 37 | + // https://datatracker.ietf.org/doc/html/rfc3875#section-4.1.2 |
|
| 38 | + if (!isset($serverParams['HTTP_CONTENT_LENGTH']) && isset($serverParams['CONTENT_LENGTH'])) { |
|
| 39 | + $serverParams['HTTP_CONTENT_LENGTH'] = $serverParams['CONTENT_LENGTH']; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - // https://datatracker.ietf.org/doc/html/rfc3875#section-4.1.3 |
|
| 43 | - if (!isset($serverParams['HTTP_CONTENT_TYPE']) && isset($serverParams['CONTENT_TYPE'])) { |
|
| 44 | - $serverParams['HTTP_CONTENT_TYPE'] = $serverParams['CONTENT_TYPE']; |
|
| 45 | - } |
|
| 42 | + // https://datatracker.ietf.org/doc/html/rfc3875#section-4.1.3 |
|
| 43 | + if (!isset($serverParams['HTTP_CONTENT_TYPE']) && isset($serverParams['CONTENT_TYPE'])) { |
|
| 44 | + $serverParams['HTTP_CONTENT_TYPE'] = $serverParams['CONTENT_TYPE']; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - $result = []; |
|
| 48 | - foreach ($serverParams as $key => $value) { |
|
| 49 | - if (0 <> strncmp('HTTP_', $key, 5)) { |
|
| 50 | - continue; |
|
| 51 | - } |
|
| 47 | + $result = []; |
|
| 48 | + foreach ($serverParams as $key => $value) { |
|
| 49 | + if (0 <> strncmp('HTTP_', $key, 5)) { |
|
| 50 | + continue; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - $name = strtr(substr($key, 5), '_', '-'); |
|
| 54 | - $name = ucwords(strtolower($name), '-'); |
|
| 53 | + $name = strtr(substr($key, 5), '_', '-'); |
|
| 54 | + $name = ucwords(strtolower($name), '-'); |
|
| 55 | 55 | |
| 56 | - $result[$name] = $value; |
|
| 57 | - } |
|
| 56 | + $result[$name] = $value; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - return $result; |
|
| 59 | + return $result; |
|
| 60 | 60 | } |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | function server_request_method(?array $serverParams = null): string |
| 25 | 25 | { |
| 26 | - $serverParams ??= $_SERVER; |
|
| 26 | + $serverParams ??= $_SERVER; |
|
| 27 | 27 | |
| 28 | - return $serverParams['REQUEST_METHOD'] ?? Request::METHOD_GET; |
|
| 28 | + return $serverParams['REQUEST_METHOD'] ?? Request::METHOD_GET; |
|
| 29 | 29 | } |