Completed
Push — master ( 879b99...0942ba )
by Luis Andrés
01:13 queued 11s
created

FinalCustomer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace Luilliarcec\LaravelEcuadorIdentification\Support\Identifications;
5
6
7
use Luilliarcec\LaravelEcuadorIdentification\Contracts\IdentificationContract;
8
use Luilliarcec\LaravelEcuadorIdentification\Exceptions\EcuadorIdentificationException;
9
10
class FinalCustomer extends EcuadorValidations implements IdentificationContract
11
{
12
    /**
13
     * FinalCustomer constructor.
14
     */
15
    public function __construct()
16
    {
17
        parent::__construct();
18
19
        $this->billingCode = config('laravel-ecuador-identification.type-identifications.final-customer.billing-code');
0 ignored issues
show
Documentation Bug introduced by
It seems like config('laravel-ecuador-...customer.billing-code') of type * is incompatible with the declared type array of property $billingCode.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
20
    }
21
22
    /**
23
     * Validate this identification
24
     *
25
     * @param string $number
26
     * @return \Illuminate\Config\Repository|mixed|string
27
     * @throws EcuadorIdentificationException
28
     */
29
    public function validate(string $number)
30
    {
31
        try {
32
            if ($number != config('laravel-ecuador-identification.final-customer.unique-value')) {
33
                throw new EcuadorIdentificationException("Field is invalid");
34
            }
35
        } catch (EcuadorIdentificationException $e) {
36
            throw new EcuadorIdentificationException($e->getMessage());
37
        }
38
39
        return $this->billingCode;
40
    }
41
}
42