| Conditions | 7 |
| Paths | 9 |
| Total Lines | 23 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 18 | public function validate($value, Constraint $constraint) |
||
| 19 | { |
||
| 20 | parent::validate($value, $constraint); |
||
| 21 | |||
| 22 | if (!$value) { |
||
| 23 | return; |
||
| 24 | } |
||
| 25 | |||
| 26 | if ($constraint->country == ZipCode::ALL) { |
||
| 27 | $validated = false; |
||
| 28 | foreach (IsoCodes\ZipCode::getAvailableCountries() as $country) { |
||
| 29 | if (IsoCodes\ZipCode::validate($value, $country)) { |
||
| 30 | $validated = true; |
||
| 31 | break; |
||
| 32 | } |
||
| 33 | } |
||
| 34 | if ($validated === false) { |
||
| 35 | $this->createViolation($constraint->message); |
||
| 36 | } |
||
| 37 | } elseif (!IsoCodes\ZipCode::validate($value, $constraint->country)) { |
||
| 38 | $this->createViolation($constraint->message); |
||
| 39 | } |
||
| 40 | } |
||
| 41 | } |
||
| 42 |