Passed
Push — master ( 193ce8...245a1c )
by Antonio Oertel
05:00 queued 02:20
created

CnsCalculator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 0
cbo 1
dl 0
loc 20
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A calculateDigit() 0 14 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 10
    public function calculateDigit($baseNumber)
14
    {
15 10
        $pis = substr($baseNumber, 0, 11);
16
17 10
        $calculator = new DigitCalculator($pis);
18 10
        $calculator->useComplementaryInsteadOfModule();
19 10
        $calculator->replaceWhen('8', 10);
20 10
        $calculator->replaceWhen('0', 11);
21 10
        $calculator->withMultipliersInterval(5, 15);
22
23 10
        $digit = $calculator->calculate();
24
25 10
        return "{$digit}";
26
    }
27
}
28