Completed
Push — master ( 0a980f...55a91e )
by Luis Andrés
01:47 queued 11s
created

PersonalIdentification::__construct()   A

Complexity

Conditions 1
Paths 1

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 1
nc 1
nop 0
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 PersonalIdentification 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
     * PersonalIdentification constructor.
12
     */
13
    public function __construct()
14
    {
15
        $this->lenght = 10;
16
        $this->billingCode = '05';
17
        $this->coefficients = [2, 1, 2, 1, 2, 1, 2, 1, 2];
18
        $this->checkDigitPosition = 10;
19
        $this->thirdDigit = 5;
20
    }
21
22
    protected function thirdDigitValidation(string $identification_number): void
23
    {
24
        $third_digit = $this->getThirdDigitValue($identification_number);
25
26
        if ($third_digit > $this->thirdDigit) {
27
            throw new IdentificationException("Field must have the third digit less than or equal to {$this->thirdDigit}.");
28
        }
29
    }
30
}
31