Conditions | 4 |
Paths | 4 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4.0119 |
Changes | 0 |
1 | <?php |
||
11 | 12 | public function validate($value, Constraint $constraint) |
|
12 | { |
||
13 | 12 | if (!$constraint instanceof Kad) { |
|
14 | throw new UnexpectedTypeException($constraint, Kad::class); |
||
15 | } |
||
16 | |||
17 | 12 | if (empty($value)) { |
|
18 | 2 | return; |
|
19 | } |
||
20 | |||
21 | 10 | if (!preg_match('/^([0-9]{2}\.){3}[0-9]{2}$/', $value)) { |
|
22 | 5 | $this->context->buildViolation($constraint->message) |
|
23 | 5 | ->setParameter('{{ string }}', $value) |
|
24 | 5 | ->addViolation(); |
|
25 | |||
26 | 5 | return; |
|
27 | } |
||
28 | } |
||
29 | } |