Conditions | 9 |
Paths | 24 |
Total Lines | 26 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 9.5338 |
Changes | 0 |
1 | <?php |
||
34 | 3 | public function generateVerifyCode() |
|
35 | { |
||
36 | 3 | if ($this->minLength > $this->maxLength) { |
|
37 | $this->maxLength = $this->minLength; |
||
38 | } |
||
39 | 3 | if ($this->minLength < 3) { |
|
40 | $this->minLength = 3; |
||
41 | } |
||
42 | 3 | if ($this->maxLength > 20) { |
|
43 | $this->maxLength = 20; |
||
44 | } |
||
45 | 3 | $length = mt_rand($this->minLength, $this->maxLength); |
|
46 | |||
47 | 3 | $letters = 'bcdfghjklmnpqrstvwxyz'; |
|
48 | 3 | $vowels = 'aeiou'; |
|
49 | 3 | $code = ''; |
|
50 | 3 | for ($i = 0; $i < $length; ++$i) { |
|
51 | 3 | if ($i % 2 && mt_rand(0, 10) > 2 || !($i % 2) && mt_rand(0, 10) > 9) { |
|
52 | 3 | $code .= $vowels[mt_rand(0, 4)]; |
|
53 | } else { |
||
54 | 3 | $code .= $letters[mt_rand(0, 20)]; |
|
55 | } |
||
56 | } |
||
57 | |||
58 | 3 | return $code; |
|
59 | } |
||
60 | } |