Completed
Push — master ( a9c19a...6eb712 )
by Marcel
09:39
created

validateVatNumber()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 1
Metric Value
c 3
b 1
f 1
dl 0
loc 12
rs 9.4285
cc 2
eloc 7
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
    /**
13
     * Usage: vat_number.
14
     *
15
     * @param string $attribute
16
     * @param mixed $value
17
     * @param array $parameters
18
     * @param $validator
19
     *
20
     * @return bool
21
     */
22
    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...
23
    {
24
        $validator->setCustomMessages([
25
            'vat_number' => $validator->getTranslator()->get('vatnumber-validator::validation.vat_number'),
26
        ]);
27
28
        try {
29
            return VatCalculator::isValidVATNumber($value);
30
        } catch (VATCheckUnavailableException $e) {
31
            return false;
32
        }
33
    }
34
}
35