ReactHttpServerFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 11
c 1
b 0
f 0
dl 0
loc 19
ccs 0
cts 9
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Antidot\React\Container;
6
7
use Antidot\React\ReactHttpServer;
8
use Psr\Container\ContainerInterface;
9
use Webmozart\Assert\Assert;
10
11
class ReactHttpServerFactory
12
{
13
    private const REQUIRED_FILE_PATH_CONFIGS = [
14
        'container_path',
15
        'router_path',
16
        'middleware_path',
17
    ];
18
19
    public function __invoke(ContainerInterface $container): ReactHttpServer
20
    {
21
        $config = $container->get('config')['react_http_server'];
22
23
        Assert::keyExists($config, 'uri');
24
        foreach (self::REQUIRED_FILE_PATH_CONFIGS as $filePathConfig) {
25
            Assert::keyExists($config, $filePathConfig);
26
            Assert::fileExists($config[$filePathConfig]);
27
        }
28
29
        return new ReactHttpServer($config);
30
    }
31
}
32