| Conditions | 5 |
| Paths | 2 |
| Total Lines | 33 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function stream( |
||
| 16 | ResponseFactoryInterface $responseFactory |
||
| 17 | ): ResponseInterface { |
||
| 18 | if (\function_exists('pcntl_signal')) { |
||
| 19 | \pcntl_signal(\SIGINT, static function (): void { |
||
| 20 | exit(1); |
||
| 21 | }); |
||
| 22 | } |
||
| 23 | |||
| 24 | $socket = Connection::create(); |
||
| 25 | $socket->bind(); |
||
| 26 | |||
| 27 | return $responseFactory->createResponse() |
||
| 28 | ->withHeader(Header::CONTENT_TYPE, 'text/event-stream') |
||
| 29 | ->withHeader(Header::CACHE_CONTROL, 'no-cache') |
||
| 30 | ->withHeader(Header::CONNECTION, 'keep-alive') |
||
| 31 | ->withBody( |
||
| 32 | new ServerSentEventsStream(function () use ($socket) { |
||
| 33 | foreach ($socket->read() as $message) { |
||
| 34 | switch ($message[0]) { |
||
| 35 | case Connection::TYPE_ERROR: |
||
| 36 | return ''; |
||
| 37 | default: |
||
| 38 | /** |
||
| 39 | * Break the loop if the client aborted the connection (closed the page) |
||
| 40 | */ |
||
| 41 | if (connection_aborted()) { |
||
| 42 | return $message[1]; |
||
| 43 | } |
||
| 44 | yield $message[1]; |
||
| 45 | } |
||
| 46 | } |
||
| 47 | return ''; |
||
| 48 | }) |
||
| 52 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths