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

NaturalRuc::validate()   A

Complexity

Conditions 2
Paths 4

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
c 0
b 0
f 0
rs 9.8666
cc 2
nc 4
nop 1
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 View Code Duplication
class NaturalRuc extends EcuadorValidations implements IdentificationContract
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    /**
13
     * NaturalRuc constructor.
14
     */
15
    public function __construct()
16
    {
17
        parent::__construct();
18
19
        $this->lenght = config('laravel-ecuador-identification.type-identifications.ruc.length');
0 ignored issues
show
Documentation Bug introduced by
It seems like config('laravel-ecuador-...ifications.ruc.length') of type * is incompatible with the declared type array of property $lenght.

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
        $this->billingCode = config('laravel-ecuador-identification.type-identifications.ruc.billing-code');
0 ignored issues
show
Documentation Bug introduced by
It seems like config('laravel-ecuador-...ions.ruc.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...
21
    }
22
23
    /**
24
     * Validate this identification
25
     *
26
     * @param string $number
27
     * @return \Illuminate\Config\Repository|mixed|string
28
     * @throws EcuadorIdentificationException
29
     */
30
    public function validate(string $number)
31
    {
32
        try {
33
            $this->validateInitial($number, $this);
34
            $this->validateLastDigits(substr($number, 10, 3), $this);
35
            $this->moduleTen($number);
36
        } catch (EcuadorIdentificationException $e) {
37
            throw new EcuadorIdentificationException($e->getMessage());
38
        }
39
40
        return $this->billingCode;
41
    }
42
}
43