Passed
Push — 2.0.x ( fad8f9...71e097 )
by Koldo
02:49
created

SocketFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 14
ccs 8
cts 8
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
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 1
    public function __invoke(ContainerInterface $container): Socket
14
    {
15
        /** @var LoopInterface $loop */
16 1
        $loop = $container->get(LoopInterface::class);
17
        /** @var array<string, array> $globalConfig */
18 1
        $globalConfig = $container->get('config');
19
        /** @var array<string, string|null> $config */
20 1
        $config = $globalConfig['server'];
21
22 1
        return new Socket(sprintf(
23 1
            '%s:%s',
24 1
            $config['host'] ?? '0.0.0.0',
25 1
            $config['port'] ?? '8080'
26
        ), $loop);
27
    }
28
}
29