Passed
Branch master (ba77f4)
by Aimeos
03:57
created

Typo3::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
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
0 ignored issues
show
Bug introduced by
The type Aimeos\MShop\Common\Helper\Password\Associative was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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