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