Passed
Push — develop ( 3b27a1...7bbf61 )
by Baptiste
02:37
created

Validate2FACodeHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 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
12
final class Validate2FACodeHandler
13
{
14
    private $repository;
15
16 2
    public function __construct(IdentityRepository $repository)
17
    {
18 2
        $this->repository = $repository;
19 2
    }
20
21 2
    public function __invoke(Validate2FACode $wished): void
22
    {
23 2
        $identity = $this->repository->get($wished->email());
24
25 2
        if (!$identity->validate($wished->code())) {
26 1
            throw new Invalid2FACode($wished->code());
27
        }
28 1
    }
29
}
30