IpResolver::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Karser\Recaptcha3Bundle\Services;
4
5
use Symfony\Component\HttpFoundation\RequestStack;
6
7
final class IpResolver implements IpResolverInterface
8
{
9
    /** @var RequestStack */
10
    private $requestStack;
11
12 5
    public function __construct(RequestStack $requestStack)
13
    {
14 5
        $this->requestStack = $requestStack;
15 5
    }
16
17 4
    public function resolveIp(): ?string
18
    {
19 4
        $request = $this->requestStack->getCurrentRequest();
20 4
        if ($request === null) {
21 2
            return null;
22
        }
23 2
        return $request->getClientIp();
24
    }
25
}
26