Passed
Branch main (274970)
by Antonio Oertel
03:05
created

CnsCalculator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
dl 0
loc 18
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 1
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A calculateDigit() 0 13 1
1
<?php
2
3
namespace Brazanation\Documents\Cns;
4
5
use Brazanation\Documents\DigitCalculable;
6
use Brazanation\Documents\DigitCalculator;
7
8
final class CnsCalculator implements DigitCalculable
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13 20
    public function calculateDigit(string $baseNumber) : string
14
    {
15 20
        $pis = substr($baseNumber, 0, 11);
16
17 20
        $calculator = new DigitCalculator($pis);
18 20
        $calculator->useComplementaryInsteadOfModule();
19 20
        $calculator->replaceWhen('8', 10);
20 20
        $calculator->replaceWhen('0', 11);
21 20
        $calculator->withMultipliersInterval(5, 15);
22
23 20
        $digit = $calculator->calculate();
24
25 20
        return "{$digit}";
26
    }
27
}
28