Completed
Push — master ( 379b70...ba77f4 )
by Aimeos
01:23
created

Typo3::encode()   A

Complexity

Conditions 2
Paths 2

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 2
nc 2
nop 2
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2018
6
 * @package MShop
7
 * @subpackage Common
8
 */
9
10
11
namespace Aimeos\MShop\Common\Helper\Password;
12
13
14
/**
15
 * TYPO3 implementation of the password helper item
16
 *
17
 * @package MShop
18
 * @subpackage Common
19
 */
20
class Typo3 implements \Aimeos\MShop\Common\Helper\Password\Iface
21
{
22
	private $hasher;
23
24
25
	/**
26
	 * Initializes the password helper.
27
	 *
28
	 * @param array Associative list of key/value pairs of options specific for the hashing method
29
	 */
30
	public function __construct( array $options )
31
	{
32
		if( !array_key_exists( 'object', $options ) ) {
33
			throw new \Aimeos\MShop\Exception( sprintf( 'No TYPO3 password hash object available' ) );
34
		}
35
36
		$this->hasher = $options['object'];
37
	}
38
39
40
	/**
41
	 * Returns the hashed password.
42
	 *
43
	 * @param string $password Clear text password string
44
	 * @param string|null $salt Password salt
45
	 * @return string Hashed password
46
	 */
47
	public function encode( $password, $salt = null )
48
	{
49
		return ( isset( $this->hasher ) ? $this->hasher->getHashedPassword( $password, $salt ) : $password );
50
	}
51
}
52