Conditions | 2 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
24 | public static function fromPlainText(string $plainTextValue) |
||
25 | { |
||
26 | if (!preg_match('/^(?=[^ ])(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z])(.{8,})(?<=\S)$/', $plainTextValue)) { |
||
27 | throw new \InvalidArgumentException( |
||
28 | 'Invalid value for password. '. |
||
29 | 'Must be at least 8 characters long, contain at least one lowercase, '. |
||
30 | 'one uppercase and one non-alphabetical character and must not start or end with a space.' |
||
31 | ); |
||
32 | } |
||
33 | |||
34 | $password = new Password(); |
||
35 | $password->setValue(password_hash($plainTextValue, PASSWORD_DEFAULT)); |
||
36 | |||
37 | return $password; |
||
38 | } |
||
62 |