Completed
Pull Request — master (#2)
by Tomáš
09:55
created

DefaultPasswordHashStrategy::__construct()   A

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 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SixtyEightPublishers\User\Common\PasswordHashStrategy;
6
7
use Nette;
8
9
final class DefaultPasswordHashStrategy implements IPasswordHashStrategy
10
{
11
	use Nette\SmartObject;
12
13
	/** @var array  */
14
	private $options;
15
16
	/**
17
	 * @param array $options
18
	 */
19
	public function __construct(array $options = [])
20
	{
21
		$this->options = $options;
22
	}
23
24
	/*********** interface \SixtyEightPublishers\User\Common\PasswordHashStrategy\IPasswordHashStrategy ***********/
25
26
	/**
27
	 * {@inheritdoc}
28
	 */
29
	public function hash(string $password): string
30
	{
31
		return Nette\Security\Passwords::hash($password, $this->options);
32
	}
33
34
	/**
35
	 * {@inheritdoc}
36
	 */
37
	public function needRehash(string $password): bool
38
	{
39
		return Nette\Security\Passwords::needsRehash($password, $this->options);
40
	}
41
42
	/**
43
	 * {@inheritdoc}
44
	 */
45
	public function verify(string $password, string $hash): bool
46
	{
47
		return Nette\Security\Passwords::verify($password, $hash);
48
	}
49
}
50