| Conditions | 1 |
| Paths | 1 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 1 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | 1 | public function __invoke(ContainerInterface $container): Server |
|
| 21 | { |
||
| 22 | 1 | $application = $container->get(Application::class); |
|
| 23 | 1 | assert($application instanceof ReactApplication); |
|
| 24 | /** @var LoopInterface $loop */ |
||
| 25 | 1 | $loop = $container->get(LoopInterface::class); |
|
| 26 | /** @var array<string, array> $globalConfig */ |
||
| 27 | 1 | $globalConfig = $container->get('config'); |
|
| 28 | /** @var array<string, int|null> $config */ |
||
| 29 | 1 | $config = $globalConfig['server']; |
|
| 30 | |||
| 31 | 1 | $server = new Server( |
|
| 32 | 1 | $loop, |
|
| 33 | 1 | new StreamingRequestMiddleware(), |
|
| 34 | 1 | new LimitConcurrentRequestsMiddleware(($config['max_concurrency']) ?? 100), |
|
| 35 | 1 | new RequestBodyBufferMiddleware($config['buffer_size'] ?? 4 * 1024 * 1024), // 4 MiB |
|
| 36 | 1 | new RequestBodyParserMiddleware(), |
|
| 37 | 1 | static fn (ServerRequestInterface $request): ResponseInterface => $application->handle($request) |
|
| 38 | 1 | ); |
|
| 39 | |||
| 40 | 1 | return $server; |
|
| 41 | } |
||
| 43 |