Conditions | 4 |
Paths | 4 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | 4242 | public function validate($value, Constraint $constraint) |
|
17 | { |
||
18 | 4242 | if (empty(trim($value))) { |
|
19 | 6 | return; |
|
20 | } |
||
21 | |||
22 | 4236 | $domains = json_decode( |
|
23 | 4236 | file_get_contents(__DIR__.'/../data/domains.json'), |
|
24 | 1412 | true |
|
25 | 2824 | ); |
|
26 | |||
27 | 4236 | foreach ($domains as $domain) { |
|
28 | 4236 | if (preg_match('/@'.preg_quote($domain).'$/', $value)) { |
|
29 | 4230 | $this->context->addViolation($constraint->message, [ |
|
30 | 4230 | '%email%' => $value, |
|
31 | 4230 | '%domain%' => $domain, |
|
32 | 2820 | ]); |
|
33 | |||
34 | 4232 | return; |
|
35 | } |
||
36 | 2822 | } |
|
37 | 6 | } |
|
38 | } |
||
39 |