|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* The Mixer strategy interface. |
|
4
|
|
|
* |
|
5
|
|
|
* All mixing strategies must implement this interface |
|
6
|
|
|
* |
|
7
|
|
|
* PHP version 5.3 |
|
8
|
|
|
* |
|
9
|
|
|
* @category PHPPasswordLib |
|
10
|
|
|
* @package Random |
|
11
|
|
|
* @author Anthony Ferrara <[email protected]> |
|
12
|
|
|
* @copyright 2011 The Authors |
|
13
|
|
|
* @license http://opensource.org/licenses/bsd-license.php New BSD License |
|
14
|
|
|
* @license http://www.gnu.org/licenses/lgpl-2.1.html LGPL v 2.1 |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace RandomLibTest\Mocks\Random; |
|
18
|
|
|
|
|
19
|
|
|
use SecurityLib\Strength; |
|
20
|
|
|
/** |
|
21
|
|
|
* The Mixer strategy interface. |
|
22
|
|
|
* |
|
23
|
|
|
* All mixing strategies must implement this interface |
|
24
|
|
|
* |
|
25
|
|
|
* @category PHPPasswordLib |
|
26
|
|
|
* @package Random |
|
27
|
|
|
* @author Anthony Ferrara <[email protected]> |
|
28
|
|
|
*/ |
|
29
|
|
|
class Mixer extends \RandomLibTest\Mocks\AbstractMock implements \RandomLib\Mixer { |
|
30
|
|
|
|
|
31
|
|
|
public static $strength = null; |
|
32
|
|
|
|
|
33
|
|
|
public static $test = true; |
|
34
|
|
|
|
|
35
|
|
|
public static function init() { |
|
36
|
|
|
static::$strength = new Strength(Strength::HIGH); |
|
37
|
|
|
static::$test = true; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Return an instance of Strength indicating the strength of the mixer |
|
42
|
|
|
* |
|
43
|
|
|
* @return Strength An instance of one of the strength classes |
|
44
|
|
|
*/ |
|
45
|
|
|
public static function getStrength() { |
|
46
|
|
|
return static::$strength; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Test to see if the mixer is available |
|
51
|
|
|
* |
|
52
|
|
|
* @return boolean If the mixer is available on the system |
|
53
|
|
|
*/ |
|
54
|
|
|
public static function test() { |
|
55
|
|
|
return static::$test; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Mix the provided array of strings into a single output of the same size |
|
60
|
|
|
* |
|
61
|
|
|
* All elements of the array should be the same size. |
|
62
|
|
|
* |
|
63
|
|
|
* @param array $parts The parts to be mixed |
|
64
|
|
|
* |
|
65
|
|
|
* @return string The mixed result |
|
66
|
|
|
*/ |
|
67
|
|
|
public function mix(array $parts) { |
|
68
|
|
|
return $this->__call('mix', array($parts)); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
|