1 | <?php |
||
21 | final class UserPassword |
||
22 | { |
||
23 | /** |
||
24 | * The encoded password. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | private $encodedPassword; |
||
29 | |||
30 | /** |
||
31 | * The salt. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | private $salt; |
||
36 | |||
37 | /** |
||
38 | * Constructor. |
||
39 | * |
||
40 | * @param string $anEncodedPassword The encoded password |
||
41 | * @param string|null $salt The salt |
||
42 | */ |
||
43 | private function __construct($anEncodedPassword, $salt) |
||
48 | |||
49 | /** |
||
50 | * Named static constructor with the given encoded password. |
||
51 | * |
||
52 | * @param string $anEncodedPassword The encoded password |
||
53 | * @param string $salt The salt |
||
54 | * |
||
55 | * @return self |
||
56 | */ |
||
57 | public static function fromEncoded($anEncodedPassword, $salt) |
||
61 | |||
62 | /** |
||
63 | * Named static constructor with the given plain password and encoder. |
||
64 | * |
||
65 | * @param string $aPlainPassword The plain password |
||
66 | * @param UserPasswordEncoder $anEncoder The encoder |
||
67 | * @param string|null $salt The salt |
||
68 | * |
||
69 | * @return self |
||
70 | */ |
||
71 | public static function fromPlain($aPlainPassword, UserPasswordEncoder $anEncoder, $salt = null) |
||
80 | |||
81 | /** |
||
82 | * Method that checks if the password given is equal to the current. |
||
83 | * |
||
84 | * @param string $aPlainPassword The plain password |
||
85 | * @param UserPasswordEncoder $anEncoder The encoder |
||
86 | * |
||
87 | * @return bool |
||
88 | */ |
||
89 | public function equals($aPlainPassword, UserPasswordEncoder $anEncoder) |
||
93 | |||
94 | /** |
||
95 | * Gets the encoded password. |
||
96 | * |
||
97 | * @return string |
||
98 | */ |
||
99 | public function encodedPassword() |
||
103 | |||
104 | /** |
||
105 | * Gets the salt. |
||
106 | * |
||
107 | * @return string |
||
108 | */ |
||
109 | public function salt() |
||
113 | |||
114 | /** |
||
115 | * Magic method that represents the password in string format. |
||
116 | * |
||
117 | * @return string |
||
118 | */ |
||
119 | public function __toString() |
||
123 | } |
||
124 |