@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | ResponseFactoryInterface $responseFactory, |
| 47 | 47 | StreamFactoryInterface $streamFactory, |
| 48 | 48 | FilesInterface $files |
| 49 | - ) { |
|
| 49 | + ){ |
|
| 50 | 50 | $this->responseFactory = $responseFactory; |
| 51 | 51 | $this->streamFactory = $streamFactory; |
| 52 | 52 | $this->files = $files; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function redirect($uri, int $code = 302): ResponseInterface |
| 74 | 74 | { |
| 75 | - if (!is_string($uri) && !$uri instanceof UriInterface) { |
|
| 75 | + if (!is_string($uri) && !$uri instanceof UriInterface){ |
|
| 76 | 76 | throw new ResponseException('Redirect allowed only for string or UriInterface uris'); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | string $name = '', |
| 109 | 109 | string $mime = 'application/octet-stream' |
| 110 | 110 | ): ResponseInterface { |
| 111 | - if (empty($name)) { |
|
| 112 | - if (!is_string($filename)) { |
|
| 111 | + if (empty($name)){ |
|
| 112 | + if (!is_string($filename)){ |
|
| 113 | 113 | throw new ResponseException('Unable to resolve public filename'); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $response = $response->withHeader('Content-Length', (string)$stream->getSize()); |
| 124 | 124 | $response = $response->withHeader( |
| 125 | 125 | 'Content-Disposition', |
| 126 | - 'attachment; filename="' . addcslashes($name, '"') . '"' |
|
| 126 | + 'attachment; filename="'.addcslashes($name, '"').'"' |
|
| 127 | 127 | ); |
| 128 | 128 | |
| 129 | 129 | return $response->withBody($stream); |
@@ -156,19 +156,19 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | private function getStream($file): StreamInterface |
| 158 | 158 | { |
| 159 | - if ($file instanceof StreamableInterface) { |
|
| 159 | + if ($file instanceof StreamableInterface){ |
|
| 160 | 160 | return $file->getStream(); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if ($file instanceof StreamInterface) { |
|
| 163 | + if ($file instanceof StreamInterface){ |
|
| 164 | 164 | return $file; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if (is_resource($file)) { |
|
| 167 | + if (is_resource($file)){ |
|
| 168 | 168 | return $this->streamFactory->createStreamFromResource($file); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if (!$this->files->isFile($file)) { |
|
| 171 | + if (!$this->files->isFile($file)){ |
|
| 172 | 172 | throw new ResponseException('Unable to allocate response body stream, file does not exist'); |
| 173 | 173 | } |
| 174 | 174 | |
@@ -72,7 +72,8 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function redirect($uri, int $code = 302): ResponseInterface |
| 74 | 74 | { |
| 75 | - if (!is_string($uri) && !$uri instanceof UriInterface) { |
|
| 75 | + if (!is_string($uri) && !$uri instanceof UriInterface) |
|
| 76 | + { |
|
| 76 | 77 | throw new ResponseException('Redirect allowed only for string or UriInterface uris'); |
| 77 | 78 | } |
| 78 | 79 | |
@@ -108,8 +109,10 @@ discard block |
||
| 108 | 109 | string $name = '', |
| 109 | 110 | string $mime = 'application/octet-stream' |
| 110 | 111 | ): ResponseInterface { |
| 111 | - if (empty($name)) { |
|
| 112 | - if (!is_string($filename)) { |
|
| 112 | + if (empty($name)) |
|
| 113 | + { |
|
| 114 | + if (!is_string($filename)) |
|
| 115 | + { |
|
| 113 | 116 | throw new ResponseException('Unable to resolve public filename'); |
| 114 | 117 | } |
| 115 | 118 | |
@@ -156,19 +159,23 @@ discard block |
||
| 156 | 159 | */ |
| 157 | 160 | private function getStream($file): StreamInterface |
| 158 | 161 | { |
| 159 | - if ($file instanceof StreamableInterface) { |
|
| 162 | + if ($file instanceof StreamableInterface) |
|
| 163 | + { |
|
| 160 | 164 | return $file->getStream(); |
| 161 | 165 | } |
| 162 | 166 | |
| 163 | - if ($file instanceof StreamInterface) { |
|
| 167 | + if ($file instanceof StreamInterface) |
|
| 168 | + { |
|
| 164 | 169 | return $file; |
| 165 | 170 | } |
| 166 | 171 | |
| 167 | - if (is_resource($file)) { |
|
| 172 | + if (is_resource($file)) |
|
| 173 | + { |
|
| 168 | 174 | return $this->streamFactory->createStreamFromResource($file); |
| 169 | 175 | } |
| 170 | 176 | |
| 171 | - if (!$this->files->isFile($file)) { |
|
| 177 | + if (!$this->files->isFile($file)) |
|
| 178 | + { |
|
| 172 | 179 | throw new ResponseException('Unable to allocate response body stream, file does not exist'); |
| 173 | 180 | } |
| 174 | 181 | |