DefaultPasswordHashStrategy   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 37
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A hash() 0 4 1
A needRehash() 0 4 1
A verify() 0 4 1
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