| Conditions | 5 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | public function validate($value, Constraint $constraint) { |
||
| 22 | if(!$constraint instanceof UniqueUsername) { |
||
| 23 | throw new UnexpectedTypeException($constraint, UniqueUsername::class); |
||
| 24 | } |
||
| 25 | |||
| 26 | if(!is_string($value)) { |
||
| 27 | throw new UnexpectedTypeException($constraint, 'string'); |
||
| 28 | } |
||
| 29 | |||
| 30 | $user = $this->userRepository->findOneByUsername($value); |
||
| 31 | |||
| 32 | if($user !== null && $this->matchesType($user, $constraint->type) === false) { |
||
| 33 | $this->context |
||
| 34 | ->buildViolation($constraint->message) |
||
| 35 | ->addViolation(); |
||
| 36 | } |
||
| 43 | } |