Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
9 / 9 |
CRAP | |
100.00% |
1 / 1 |
| StrongPassword | |
100.00% |
13 / 13 |
|
100.00% |
9 / 9 |
9 | |
100.00% |
1 / 1 |
| getMinLength | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getMaxLength | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAllowedSpecialCharacters | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getMinSpecialCharacters | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getMinDigits | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getMinLowercase | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getMinUppercase | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| convert | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getOpenapiSchema | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\TextValueObjects; |
| 3 | |
| 4 | use Apie\Core\Attributes\SchemaMethod; |
| 5 | use Apie\Core\RegexUtils; |
| 6 | use Apie\Core\ValueObjects\Interfaces\HasRegexValueObjectInterface; |
| 7 | use Apie\Core\ValueObjects\IsPasswordValueObject; |
| 8 | |
| 9 | #[SchemaMethod("getOpenapiSchema")] |
| 10 | class StrongPassword implements HasRegexValueObjectInterface |
| 11 | { |
| 12 | use IsPasswordValueObject; |
| 13 | |
| 14 | public static function getMinLength(): int |
| 15 | { |
| 16 | return 6; |
| 17 | } |
| 18 | |
| 19 | public static function getMaxLength(): int |
| 20 | { |
| 21 | return 42; |
| 22 | } |
| 23 | |
| 24 | public static function getAllowedSpecialCharacters(): string |
| 25 | { |
| 26 | return '!@#$%^&*()-_+.'; |
| 27 | } |
| 28 | |
| 29 | public static function getMinSpecialCharacters(): int |
| 30 | { |
| 31 | return 1; |
| 32 | } |
| 33 | |
| 34 | public static function getMinDigits(): int |
| 35 | { |
| 36 | return 1; |
| 37 | } |
| 38 | |
| 39 | public static function getMinLowercase(): int |
| 40 | { |
| 41 | return 1; |
| 42 | } |
| 43 | |
| 44 | public static function getMinUppercase(): int |
| 45 | { |
| 46 | return 1; |
| 47 | } |
| 48 | |
| 49 | protected function convert(string $input): string |
| 50 | { |
| 51 | return trim($input); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * @return array<string, string> |
| 56 | */ |
| 57 | public static function getOpenapiSchema(): array |
| 58 | { |
| 59 | return [ |
| 60 | 'type' => 'string', |
| 61 | 'format' => 'password', |
| 62 | 'pattern' => RegexUtils::removeDelimiters(StrongPassword::getRegularExpression()), |
| 63 | ]; |
| 64 | } |
| 65 | } |