Completed
Pull Request — master (#21)
by
unknown
17:23 queued 07:25
created

VatCalculatorValidatorExtension::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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