1 | <?php |
||
13 | class SimplePassword extends BaseScalar implements Password |
||
14 | { |
||
15 | const MIN_LENGTH = 6; |
||
16 | |||
17 | protected $value; |
||
18 | |||
19 | /** |
||
20 | * @inheritdoc |
||
21 | */ |
||
22 | 24 | public static function byCleanPassword(string $cleanPassword): Password |
|
27 | |||
28 | /** |
||
29 | * SimplePassword constructor. |
||
30 | * |
||
31 | * @param string $hashedPassword |
||
32 | */ |
||
33 | 24 | public function __construct(string $hashedPassword) |
|
37 | |||
38 | 24 | private function setByHashedPassword(string $hashedPassword): void |
|
44 | |||
45 | 24 | private function validHashedPassword($hashedPassword): void |
|
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | * |
||
57 | * @throws \InvalidArgumentException if it is the same password |
||
58 | */ |
||
59 | 6 | public function changePassword(string $cleanPassword): Password |
|
69 | |||
70 | /** |
||
71 | * @inheritdoc |
||
72 | */ |
||
73 | 12 | public function verify(string $cleanPassword): bool |
|
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | * |
||
81 | * @return string |
||
82 | */ |
||
83 | 15 | public function value(): string |
|
87 | |||
88 | /** |
||
89 | * This method is not supported |
||
90 | * |
||
91 | * @param ValueObject $valueObject |
||
92 | * @return bool |
||
93 | * @throws \BadMethodCallException |
||
94 | */ |
||
95 | 3 | public function equals(ValueObject $valueObject): bool |
|
99 | |||
100 | /** |
||
101 | * @return string |
||
102 | */ |
||
103 | 3 | public function __toString(): string |
|
107 | } |
||
108 |