Total Complexity | 5 |
Total Lines | 61 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
11 | final class PasswordHasher implements HashFunction |
||
12 | { |
||
13 | /** |
||
14 | * @var int Algorithm. |
||
15 | */ |
||
16 | private $algorithm; |
||
17 | |||
18 | /** |
||
19 | * @var array Options. |
||
20 | */ |
||
21 | private $options; |
||
22 | |||
23 | /** |
||
24 | * See http://php.net/manual/en/function.password-hash.php for details. |
||
25 | * |
||
26 | * @param int $algorithm Algorithm. |
||
27 | * @param array $options Options. |
||
28 | */ |
||
29 | 1 | public function __construct(int $algorithm = PASSWORD_DEFAULT, array $options = []) |
|
30 | { |
||
31 | 1 | $this->algorithm = $algorithm; |
|
32 | 1 | $this->options = $options; |
|
33 | 1 | } |
|
34 | |||
35 | /** |
||
36 | * {@inheritDoc} |
||
37 | */ |
||
38 | 2 | public function hash(string $password): string |
|
56 | } |
||
57 | |||
58 | /** |
||
59 | * {@inheritDoc} |
||
60 | */ |
||
61 | 2 | public function compare(string $password, string $hash): bool |
|
62 | { |
||
63 | 2 | return password_verify($password, $hash); |
|
64 | } |
||
65 | |||
66 | /** |
||
67 | * @throws ErrorException Error converted to an exception. |
||
68 | */ |
||
69 | 1 | private static function errorHandler(int $severity, string $message, string $filename, int $line): void |
|
72 | } |
||
73 | } |
||
74 |