PersonalIdentification   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A thirdDigitValidation() 0 6 2
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