Passed
Pull Request — 2.0.x (#9)
by Koldo
05:09 queued 02:31
created

SocketFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 14 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