Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
9 / 9 |
| PasswordGenerator | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
9 / 9 |
| __construct($minimumLength, $maximumLength, $characterSet) | |
100.00% |
1 / 1 |
1 | |
100.00% |
4 / 4 |
|||
| generate() | |
100.00% |
1 / 1 |
1 | |
100.00% |
5 / 5 |
|||
| <?php | |
| namespace Tdd; | |
| class PasswordGenerator | |
| { | |
| private $minimumLength; | |
| private $maximumLength; | |
| private $characterSet; | |
| public function __construct($minimumLength, $maximumLength, $characterSet) | |
| { | |
| $this->minimumLength = $minimumLength; | |
| $this->maximumLength = $maximumLength; | |
| $this->characterSet = $characterSet; | |
| } | |
| public function generate() | |
| { | |
| return substr( | |
| str_shuffle(str_repeat($this->characterSet, 1 + floor($this->maximumLength / strlen($this->characterSet)))), | |
| 0, | |
| rand($this->minimumLength, $this->maximumLength) | |
| ); | |
| } | |
| } |