DefaultPasswordHashStrategy::verify()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SixtyEightPublishers\User\Common\PasswordHashStrategy;
6
7
use Nette\Security\Passwords;
8
9
final class DefaultPasswordHashStrategy implements PasswordHashStrategyInterface
10
{
11
	/** @var \Nette\Security\Passwords  */
12
	private $passwords;
13
14
	/**
15
	 * @param array $options
16
	 */
17
	public function __construct(array $options = [])
18
	{
19
		$this->passwords = new Passwords(PASSWORD_DEFAULT, $options);
20
	}
21
22
	/**
23
	 * {@inheritdoc}
24
	 */
25
	public function hash(string $password): string
26
	{
27
		return $this->passwords->hash($password);
28
	}
29
30
	/**
31
	 * {@inheritdoc}
32
	 */
33
	public function needRehash(string $password): bool
34
	{
35
		return $this->passwords->needsRehash($password);
36
	}
37
38
	/**
39
	 * {@inheritdoc}
40
	 */
41
	public function verify(string $password, string $hash): bool
42
	{
43
		return $this->passwords->verify($password, $hash);
44
	}
45
}
46