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

NaturalRuc   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 33
loc 33
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A validate() 12 12 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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