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