VatCalculatorValidatorExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validateVatNumber() 0 12 2
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