Completed
Branch master (55a91e)
by Luis Andrés
01:36 queued 26s
created

NaturalRuc::thirdDigitValidation()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
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