validateVatNumber()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 4
1
<?php
2
3
namespace Mpociot\VatCalculator\Validators;
4
5
use Illuminate\Validation\Validator;
6
use Mpociot\VatCalculator\Exceptions\VATCheckUnavailableException;
7
use Mpociot\VatCalculator\Facades\VatCalculator;
8
9
class VatCalculatorValidatorExtension
10
{
11
    /**
12
     * Usage: vat_number.
13
     *
14
     * @param string $attribute
15
     * @param mixed  $value
16
     * @param array  $parameters
17
     * @param $validator
18
     *
19
     * @return bool
20
     */
21
    public function validateVatNumber($attribute, $value, $parameters, $validator)
0 ignored issues
show
Unused Code introduced by
The parameter $attribute is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $parameters is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23
        $validator->setCustomMessages([
24
            'vat_number' => $validator->getTranslator()->get('vatnumber-validator::validation.vat_number'),
25
        ]);
26
27
        try {
28
            return VatCalculator::isValidVATNumber($value);
29
        } catch (VATCheckUnavailableException $e) {
30
            return false;
31
        }
32
    }
33
}
34