Conditions | 4 |
Paths | 8 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
7 | public function isPasswordComplex(string $password):array |
||
8 | { |
||
9 | $errors = array(); |
||
10 | $errors["success"] = true; |
||
11 | $errors["message"] = null; |
||
12 | |||
13 | if (strlen($password) < 8) { |
||
14 | $errors["success"] = false; |
||
15 | $errors["message"] = "Password too short!"; |
||
16 | } |
||
17 | |||
18 | if (!preg_match("#[0-9]+#", $password)) { |
||
19 | $errors["success"] = false; |
||
20 | $errors["message"] = "Password must include at least one number!"; |
||
21 | } |
||
22 | |||
23 | if (!preg_match("#[a-zA-Z]+#", $password)) { |
||
24 | $errors["success"] = false; |
||
25 | $errors["message"] = "Password must include at least one letter!"; |
||
26 | } |
||
27 | |||
28 | return $errors; |
||
29 | } |
||
30 | } |