| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 37 | public static function createNew(string $password): UserPassword |
||
| 38 | { |
||
| 39 | $validator = new Validator(new SimpleRuleHandlerContainer()); |
||
| 40 | $rules = [ |
||
| 41 | new Required(), |
||
| 42 | new HasLength(min: 8), |
||
| 43 | ]; |
||
| 44 | |||
| 45 | $result = $validator->validate($password, $rules); |
||
| 46 | if (!$result->isValid()) { |
||
| 47 | foreach ($result->getErrorMessages() as $errorMessage) { |
||
| 48 | throw new UserPasswordException($errorMessage); |
||
| 49 | } |
||
| 50 | } |
||
| 51 | |||
| 52 | return new UserPassword($password); |
||
| 53 | } |
||
| 55 |