PersonalIdentification::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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