IpAddressMiddlewareFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

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