| Conditions | 1 |
| Paths | 1 |
| Total Lines | 29 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 1.0008 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | 6 | public function __invoke(ContainerInterface $container): Server |
|
| 21 | { |
||
| 22 | 6 | $application = $container->get(Application::class); |
|
| 23 | 6 | Assertion::isInstanceOf($application, ReactApplication::class); |
|
| 24 | /** @var LoopInterface $loop */ |
||
| 25 | 5 | $loop = $container->get(LoopInterface::class); |
|
| 26 | /** @var array<string, array> $globalConfig */ |
||
| 27 | 5 | $globalConfig = $container->get('config'); |
|
| 28 | /** @var array<string, int|null> $config */ |
||
| 29 | 5 | $config = $globalConfig['server']; |
|
| 30 | 5 | Assertion::keyExists($config, 'max_concurrency'); |
|
| 31 | 4 | Assertion::keyExists($config, 'buffer_size'); |
|
| 32 | 3 | Assertion::integer($config['max_concurrency']); |
|
| 33 | 2 | Assertion::integer($config['buffer_size']); |
|
| 34 | |||
| 35 | 1 | $server = new Server( |
|
| 36 | 1 | $loop, |
|
| 37 | 1 | new StreamingRequestMiddleware(), |
|
| 38 | 1 | new LimitConcurrentRequestsMiddleware($config['max_concurrency']), |
|
| 39 | 1 | new RequestBodyBufferMiddleware($config['buffer_size']), |
|
| 40 | 1 | new RequestBodyParserMiddleware(), |
|
| 41 | 1 | static function (ServerRequestInterface $request) use ($application) { |
|
| 42 | return $application |
||
| 43 | ->handle($request) |
||
| 44 | ->then([ResolveGenerator::class, 'toResponse']); |
||
| 45 | 1 | } |
|
| 46 | ); |
||
| 47 | |||
| 48 | 1 | return $server; |
|
| 49 | } |
||
| 51 |