Typo3::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2021-2025
6
 * @package MW
7
 * @subpackage Password
8
 */
9
10
11
namespace Aimeos\Base\Password;
12
13
14
/**
15
 * TYPO3 implementation of the password helper
16
 *
17
 * @package MW
18
 * @subpackage Password
19
 */
20
class Typo3 implements \Aimeos\Base\Password\Iface
21
{
22
	private \TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashInterface $hasher;
23
24
25
	/**
26
	 * Initializes the password helper
27
	 *
28
	 * @param \TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashInterface $hasher TYPO3 password hasher object
29
	 */
30
	public function __construct( \TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashInterface $hasher )
31
	{
32
		$this->hasher = $hasher;
33
	}
34
35
36
	/**
37
	 * Returns the hashed password
38
	 *
39
	 * @param string $password Clear text password string
40
	 * @return string Hashed password
41
	 */
42
	public function hash( string $password ) : string
43
	{
44
		return $this->hasher->getHashedPassword( $password );
45
	}
46
47
48
	/**
49
	 * Verifies the password
50
	 *
51
	 * @param string $password Clear text password string
52
	 * @param string $hash Hashed password
53
	 * @return bool TRUE if password and hash match
54
	 */
55
	public function verify( string $password, string $hash ) : bool
56
	{
57
		return $this->hasher->checkPassword( $password, $hash );
58
	}
59
}
60