ReactHttpServer::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Antidot\React;
6
7
use Antidot\Application\Http\Application;
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
class ReactHttpServer extends Command
13
{
14
    public const NAME = 'react-server:http';
15
    private array $config;
16
17
    public function __construct(array $config)
18
    {
19
        parent::__construct();
20
        $this->config = $config;
21
    }
22
23
    protected function configure(): void
24
    {
25
        $this->setName(self::NAME);
26
    }
27
28
    protected function execute(InputInterface $input, OutputInterface $output)
29
    {
30
        $middleware = require $this->config['middleware_path'];
31
        $routes = require $this->config['router_path'];
32
        $container = require $this->config['container_path'];
33
        /** @var Application $application */
34
        $application = $container->get(Application::class);
35
        $middleware($application, $container);
36
        $routes($application, $container);
37
38
        $application->run();
39
    }
40
}
41