Completed
Push — develop ( 7bbf61...0e334e )
by Baptiste
02:42
created

VerifyPasswordHandler::__construct()   A

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 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace PersonalGalaxy\Identity\Handler\Identity;
5
6
use PersonalGalaxy\Identity\{
7
    Command\Identity\VerifyPassword,
8
    Repository\IdentityRepository,
9
    Exception\InvalidPassword,
10
};
11
12
final class VerifyPasswordHandler
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(VerifyPassword $wished): void
22
    {
23 2
        $identity = $this->repository->get($wished->email());
24
25 2
        if (!$identity->verify($wished->password())) {
26 1
            throw new InvalidPassword;
27
        }
28 1
    }
29
}
30