@@ -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 | } |
@@ -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 | } |
@@ -29,24 +29,24 @@ |
||
29 | 29 | */ |
30 | 30 | function server_request_protocol_version(?array $serverParams = null): string |
31 | 31 | { |
32 | - $serverParams ??= $_SERVER; |
|
32 | + $serverParams ??= $_SERVER; |
|
33 | 33 | |
34 | - if (!isset($serverParams['SERVER_PROTOCOL'])) { |
|
35 | - return '1.1'; |
|
36 | - } |
|
34 | + if (!isset($serverParams['SERVER_PROTOCOL'])) { |
|
35 | + return '1.1'; |
|
36 | + } |
|
37 | 37 | |
38 | - // "HTTP" "/" 1*digit "." 1*digit |
|
39 | - sscanf($serverParams['SERVER_PROTOCOL'], 'HTTP/%d.%d', $major, $minor); |
|
38 | + // "HTTP" "/" 1*digit "." 1*digit |
|
39 | + sscanf($serverParams['SERVER_PROTOCOL'], 'HTTP/%d.%d', $major, $minor); |
|
40 | 40 | |
41 | - // e.g.: HTTP/1.1 |
|
42 | - if (isset($minor)) { |
|
43 | - return sprintf('%d.%d', $major, $minor); |
|
44 | - } |
|
41 | + // e.g.: HTTP/1.1 |
|
42 | + if (isset($minor)) { |
|
43 | + return sprintf('%d.%d', $major, $minor); |
|
44 | + } |
|
45 | 45 | |
46 | - // e.g.: HTTP/2 |
|
47 | - if (isset($major)) { |
|
48 | - return sprintf('%d', $major); |
|
49 | - } |
|
46 | + // e.g.: HTTP/2 |
|
47 | + if (isset($major)) { |
|
48 | + return sprintf('%d', $major); |
|
49 | + } |
|
50 | 50 | |
51 | - return '1.1'; |
|
51 | + return '1.1'; |
|
52 | 52 | } |
@@ -32,35 +32,35 @@ |
||
32 | 32 | */ |
33 | 33 | function server_request_uri(?array $serverParams = null): UriInterface |
34 | 34 | { |
35 | - $serverParams ??= $_SERVER; |
|
35 | + $serverParams ??= $_SERVER; |
|
36 | 36 | |
37 | - if (array_key_exists('HTTPS', $serverParams)) { |
|
38 | - if (! ('off' === $serverParams['HTTPS'])) { |
|
39 | - $scheme = 'https://'; |
|
40 | - } |
|
41 | - } |
|
37 | + if (array_key_exists('HTTPS', $serverParams)) { |
|
38 | + if (! ('off' === $serverParams['HTTPS'])) { |
|
39 | + $scheme = 'https://'; |
|
40 | + } |
|
41 | + } |
|
42 | 42 | |
43 | - if (array_key_exists('HTTP_HOST', $serverParams)) { |
|
44 | - $host = $serverParams['HTTP_HOST']; |
|
45 | - } elseif (array_key_exists('SERVER_NAME', $serverParams)) { |
|
46 | - $host = $serverParams['SERVER_NAME']; |
|
47 | - if (array_key_exists('SERVER_PORT', $serverParams)) { |
|
48 | - $host .= ':' . $serverParams['SERVER_PORT']; |
|
49 | - } |
|
50 | - } |
|
43 | + if (array_key_exists('HTTP_HOST', $serverParams)) { |
|
44 | + $host = $serverParams['HTTP_HOST']; |
|
45 | + } elseif (array_key_exists('SERVER_NAME', $serverParams)) { |
|
46 | + $host = $serverParams['SERVER_NAME']; |
|
47 | + if (array_key_exists('SERVER_PORT', $serverParams)) { |
|
48 | + $host .= ':' . $serverParams['SERVER_PORT']; |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - if (array_key_exists('REQUEST_URI', $serverParams)) { |
|
53 | - $target = $serverParams['REQUEST_URI']; |
|
54 | - } elseif (array_key_exists('PHP_SELF', $serverParams)) { |
|
55 | - $target = $serverParams['PHP_SELF']; |
|
56 | - if (array_key_exists('QUERY_STRING', $serverParams)) { |
|
57 | - $target .= '?' . $serverParams['QUERY_STRING']; |
|
58 | - } |
|
59 | - } |
|
52 | + if (array_key_exists('REQUEST_URI', $serverParams)) { |
|
53 | + $target = $serverParams['REQUEST_URI']; |
|
54 | + } elseif (array_key_exists('PHP_SELF', $serverParams)) { |
|
55 | + $target = $serverParams['PHP_SELF']; |
|
56 | + if (array_key_exists('QUERY_STRING', $serverParams)) { |
|
57 | + $target .= '?' . $serverParams['QUERY_STRING']; |
|
58 | + } |
|
59 | + } |
|
60 | 60 | |
61 | - return new Uri( |
|
62 | - ($scheme ?? 'http://') . |
|
63 | - ($host ?? 'localhost') . |
|
64 | - ($target ?? '/') |
|
65 | - ); |
|
61 | + return new Uri( |
|
62 | + ($scheme ?? 'http://') . |
|
63 | + ($host ?? 'localhost') . |
|
64 | + ($target ?? '/') |
|
65 | + ); |
|
66 | 66 | } |