Validate2FACodeHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 19
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A __invoke() 0 6 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace PersonalGalaxy\Identity\Handler\Identity;
5
6
use PersonalGalaxy\Identity\{
7
    Command\Identity\Validate2FACode,
8
    Repository\IdentityRepository,
9
    Exception\Invalid2FACode,
10
};
11
use Innmind\TimeContinuum\TimeContinuumInterface;
12
13
final class Validate2FACodeHandler
14
{
15
    private $repository;
16
    private $clock;
17
18 2
    public function __construct(
19
        IdentityRepository $repository,
20
        TimeContinuumInterface $clock
21
    ) {
22 2
        $this->repository = $repository;
23 2
        $this->clock = $clock;
24 2
    }
25
26 2
    public function __invoke(Validate2FACode $wished): void
27
    {
28 2
        $identity = $this->repository->get($wished->identity());
29
30 2
        if (!$identity->validate($wished->code(), $this->clock)) {
31 1
            throw new Invalid2FACode($wished->code());
32
        }
33 1
    }
34
}
35