Test Failed
Push — allow_fork_server ( abd9ca )
by Koldo
03:39
created

SocketFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 13
ccs 0
cts 7
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 Psr\Container\ContainerInterface;
8
use React\EventLoop\LoopInterface;
9
use React\Socket\Server as Socket;
10
11
class SocketFactory
12
{
13
    public function __invoke(ContainerInterface $container): Socket
14
    {
15
        /** @var LoopInterface $loop */
16
        $loop = $container->get(LoopInterface::class);
17
        /** @var array<string, array> $globalConfig */
18
        $globalConfig = $container->get('config');
19
        /** @var array<string, string|null> $config */
20
        $config = $globalConfig['server'];
21
22
        return new Socket(
23
            sprintf('%s:%s', $config['host'] ?? '0.0.0.0', $config['port'] ?? '8080'),
24
            $loop,
25
            ['tcp' => ['so_reuseport' => 2 <= $config['workers']]]
26
        );
27
    }
28
}
29