Completed
Push — master ( 0a980f...55a91e )
by Luis Andrés
01:47 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
namespace Luilliarcec\LaravelEcuadorIdentification\Support\Identifications;
4
5
use Luilliarcec\LaravelEcuadorIdentification\Exceptions\IdentificationException;
6
use Luilliarcec\LaravelEcuadorIdentification\Support\BaseIdentification;
7
8 View Code Duplication
class NaturalRuc extends BaseIdentification
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...
9
{
10
    /**
11
     * NaturalRuc constructor.
12
     */
13
    public function __construct()
14
    {
15
        $this->lenght = 13;
16
        $this->billingCode = '04';
17
        $this->coefficients = [2, 1, 2, 1, 2, 1, 2, 1, 2];
18
        $this->checkDigitPosition = 10;
19
        $this->thirdDigit = 5;
20
        $this->lastDigits = '001';
21
    }
22
23
    protected function thirdDigitValidation(string $identification_number): void
24
    {
25
        $third_digit = $this->getThirdDigitValue($identification_number);
26
27
        if ($third_digit > $this->thirdDigit) {
28
            throw new IdentificationException("Field must have the third digit less than or equal to {$this->thirdDigit}.");
29
        }
30
    }
31
}
32