| Conditions | 7 |
| Paths | 48 |
| Total Lines | 28 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | public static function generatePassword($length=9, $strength=0) { |
||
| 14 | $vowels = 'aeuy'; |
||
| 15 | $consonants = 'bdghjmnpqrstvz'; |
||
| 16 | if ($strength & 1) { |
||
| 17 | $consonants .= 'BDGHJLMNPQRSTVWXZ'; |
||
| 18 | } |
||
| 19 | if ($strength & 2) { |
||
| 20 | $vowels .= "AEUY"; |
||
| 21 | } |
||
| 22 | if ($strength & 4) { |
||
| 23 | $consonants .= '23456789'; |
||
| 24 | } |
||
| 25 | if ($strength & 8) { |
||
| 26 | $consonants .= '@#$%'; |
||
| 27 | } |
||
| 28 | |||
| 29 | $password = ''; |
||
| 30 | $alt = time() % 2; |
||
| 31 | for ($i = 0; $i < $length; $i++) { |
||
| 32 | if ($alt == 1) { |
||
| 33 | $password .= $consonants[(rand() % strlen($consonants))]; |
||
| 34 | $alt = 0; |
||
| 35 | } else { |
||
| 36 | $password .= $vowels[(rand() % strlen($vowels))]; |
||
| 37 | $alt = 1; |
||
| 38 | } |
||
| 39 | } |
||
| 40 | return $password; |
||
| 41 | } |
||
| 52 | } |