| Conditions | 3 |
| Paths | 3 |
| Total Lines | 24 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 3.0021 |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | 3 | public function resolve(Constraint $constraint, FormInterface $form, RuleCollection $collection) |
|
| 24 | { |
||
| 25 | /** @var \Symfony\Component\Validator\Constraints\Url $constraint */ |
||
| 26 | 3 | if (!$this->supports($constraint, $form)) { |
|
| 27 | 2 | throw new LogicException(); |
|
| 28 | } |
||
| 29 | |||
| 30 | // jquery validate only validates https, http, ftp |
||
| 31 | // So don't add the rule if there is some other protocol |
||
| 32 | 1 | $diff = array_diff($constraint->protocols, array('http', 'https', 'ftp')); |
|
| 33 | 1 | if (!empty($diff)) { |
|
| 34 | return; |
||
| 35 | } |
||
| 36 | |||
| 37 | 1 | $collection->set( |
|
| 38 | 1 | self::RULE_NAME, |
|
| 39 | 1 | new ConstraintRule( |
|
| 40 | 1 | self::RULE_NAME, |
|
| 41 | 1 | true, |
|
| 42 | 1 | new RuleMessage($constraint->message), |
|
| 43 | 1 | $constraint->groups |
|
| 44 | 1 | ) |
|
| 45 | 1 | ); |
|
| 46 | 1 | } |
|
| 47 | |||
| 53 |