IsEuVat::validate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 5
ccs 0
cts 5
cp 0
crap 6
rs 10
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