NaturalRuc::thirdDigitValidation()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Luilliarcec\LaravelEcuadorIdentification\Support\Identifications;
4
5
use Luilliarcec\LaravelEcuadorIdentification\Support\BaseIdentification;
6
7
class NaturalRuc extends BaseIdentification
8
{
9
    public function __construct()
10
    {
11
        $this->lenght = 13;
12
        $this->billingCode = '04';
13
        $this->coefficients = [2, 1, 2, 1, 2, 1, 2, 1, 2];
14
        $this->checkDigitPosition = 10;
15
        $this->thirdDigit = 5;
16
        $this->lastDigits = '001';
17
    }
18
19
    protected function thirdDigitValidation(string $identification_number): void
20
    {
21
        $third_digit = $this->getThirdDigitValue($identification_number);
22
23
        if ($third_digit > $this->thirdDigit) {
24
            throw new \Exception("Field must have the third digit less than or equal to {$this->thirdDigit}.");
25
        }
26
    }
27
}
28