| Total Complexity | 6 |
| Total Lines | 66 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class Password |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var Security $security |
||
| 16 | **/ |
||
| 17 | protected $security; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * __construct |
||
| 21 | **/ |
||
| 22 | 3 | public function __construct() |
|
| 23 | { |
||
| 24 | 3 | $this->security = new Security(); |
|
| 25 | 3 | } |
|
| 26 | |||
| 27 | /** |
||
| 28 | * hash |
||
| 29 | * |
||
| 30 | * Wrapper for yii security helper method |
||
| 31 | **/ |
||
| 32 | 3 | public function hash(string $password, int $algo, array $params = []): string |
|
| 35 | } |
||
| 36 | |||
| 37 | |||
| 38 | /** |
||
| 39 | * validate |
||
| 40 | * |
||
| 41 | * wrapper for yii security helper method |
||
| 42 | **/ |
||
| 43 | 3 | public function validate(string $password, string $hash): bool |
|
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * generate |
||
| 50 | * |
||
| 51 | * generates user-friendly random password containing at least one lower case letter, one uppercase letter and one |
||
| 52 | * digit. The remaining characters in the password are chosen at random from those three sets |
||
| 53 | * |
||
| 54 | * @see https://gist.github.com/tylerhall/521810 |
||
| 55 | **/ |
||
| 56 | 3 | public function generate(int $length): string |
|
| 78 | } |
||
| 79 | } |
||
| 80 |