| Total Complexity | 6 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | abstract class AbstractFactory implements Factory |
||
| 17 | { |
||
| 18 | protected PsrResponseFactory $responseFactory; |
||
| 19 | protected PsrStreamFactory $streamFactory; |
||
| 20 | |||
| 21 | abstract public function request(): PsrServerRequest; |
||
| 22 | |||
| 23 | 57 | public function response(int $code = 200, string $reasonPhrase = ''): PsrResponse |
|
| 26 | } |
||
| 27 | |||
| 28 | 50 | public function stream(mixed $content = ''): PsrStream |
|
| 29 | { |
||
| 30 | 50 | if (is_string($content) || $content instanceof Stringable) { |
|
| 31 | 45 | return $this->streamFactory->createStream((string)$content); |
|
| 32 | } |
||
| 33 | |||
| 34 | 8 | if (is_resource($content)) { |
|
| 35 | 4 | return $this->streamFactory->createStreamFromResource($content); |
|
| 36 | } |
||
| 37 | |||
| 38 | 4 | throw new RuntimeException('Only strings, Stringable or resources are allowed'); |
|
| 39 | } |
||
| 40 | |||
| 41 | 7 | public function streamFromFile(string $filename, string $mode = 'r'): PsrStream |
|
| 44 | } |
||
| 45 | } |
||
| 46 |