Total Complexity | 2 |
Total Lines | 25 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
7 | class ValidVatId implements Rule |
||
8 | { |
||
9 | /** |
||
10 | * Check VAT ID for validity. |
||
11 | * |
||
12 | * @param string $attribute |
||
13 | * @param mixed $value |
||
14 | * @return bool |
||
15 | */ |
||
16 | public function passes($attribute, $value) |
||
17 | { |
||
18 | // Remove all characters except letters and numbers |
||
19 | $value = preg_replace('/[^a-zA-Z0-9]]/', '', $value); |
||
20 | |||
21 | return preg_match('/[a-zA-Z]{2}[0-9]{0,12}$/', $value); |
||
|
|||
22 | } |
||
23 | |||
24 | /** |
||
25 | * Get the validation error message. |
||
26 | * |
||
27 | * @return string |
||
28 | */ |
||
29 | public function message() |
||
32 | } |
||
33 | } |
||
34 |