Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — 0.9 (#691)
by
unknown
07:33
created

Cnh   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
C validate() 0 26 7
1
<?php
2
namespace Respect\Validation\Rules;
3
4
class Cnh extends AbstractRule
5
{
6 96
    public function validate($input)
7
    {
8 96
        $ret = false;
9
10 96
        if ((strlen($input = preg_replace('/[^\d]/', '', $input)) == 11)
11 96
            && (str_repeat($input[1], 11) != $input)) {
12 48
            $dsc = 0;
13 48
            for ($i = 0, $j = 9, $v = 0; $i < 9; ++$i, --$j) {
14 48
                $v += (int) $input[$i] * $j;
15 48
            }
16
17 48
            if (($vl1 = $v % 11) >= 10) {
18 4
                $vl1 = 0;
19 4
                $dsc = 2;
20 4
            }
21
22 48
            for ($i = 0, $j = 1, $v = 0; $i < 9; ++$i, ++$j) {
23 48
                $v += (int) $input[$i] * $j;
24 48
            }
25
26 48
            $vl2 = ($x = ($v % 11)) >= 10 ? 0 : $x - $dsc;
27 48
            $ret = sprintf('%d%d', $vl1, $vl2) == substr($input, -2);
28 48
        }
29
30 96
        return $ret;
31
    }
32
}
33