IsEuVat   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 7
ccs 0
cts 5
cp 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 5 2
1
<?php
2
3
namespace kalanis\kw_rules\Rules\External;
4
5
6
use Ddeboer\Vatin\Validator;
7
use kalanis\kw_rules\Interfaces\IValidate;
8
use kalanis\kw_rules\Exceptions\RuleException;
9
use kalanis\kw_rules\Rules\ARule;
10
11
12
/**
13
 * Class IsEuVat
14
 * @package kalanis\kw_rules\Rules\External
15
 * Check if input is EU VAT number for preset country
16
 * @link https://github.com/topics/vat-number
17
 * @link https://github.com/ddeboer/vatin
18
 * @codeCoverageIgnore need external libraries
19
 */
20
class IsEuVat extends ARule
21
{
22
    public function validate(IValidate $entry): void
23
    {
24
        $validator = new Validator();
25
        if (!$validator->isValid($entry->getValue(), true)) {
26
            throw new RuleException($this->errorText);
27
        }
28
    }
29
}
30