IpAddressMiddlewareFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 1
b 0
f 0
ccs 4
cts 4
cp 1
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shlinkio\Shlink\Common\Middleware;
6
7
use Psr\Container\ContainerInterface;
8
use RKA\Middleware\IpAddress;
9
10
class IpAddressMiddlewareFactory
11
{
12
    public const REQUEST_ATTR = 'remote_address';
13
14 6
    public function __invoke(ContainerInterface $container): IpAddress
15
    {
16 6
        $config = $container->get('config');
17 6
        $headersToInspect = $config['ip_address_resolution']['headers_to_inspect'] ?? [];
18 6
        return new IpAddress(true, [], self::REQUEST_ATTR, $headersToInspect);
19
    }
20
}
21