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 (#694)
by
unknown
03:32
created

Cnpj   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 1
dl 0
loc 27
c 0
b 0
f 0
ccs 12
cts 12
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C validate() 0 24 8
1
<?php
2
namespace Respect\Validation\Rules;
3
4
class Cnpj extends AbstractRule
5
{
6 24
    public function validate($input)
7
    {
8
        //Code ported from jsfromhell.com
9 24
        $c = preg_replace('/\D/', '', $input);
10 24
        $b = array(6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2);
11
12 24
        if (strlen($c) != 14) {
13 11
            return false;
14
        }
15
16 13
        for ($i = 0, $n = 0; $i < 12; $n += $c[$i] * $b[++$i]);
17
18 13
        if ($c[12] != ((($n %= 11) < 2) ? 0 : 11 - $n)) {
19 1
            return false;
20
        }
21
22 12
        for ($i = 0, $n = 0; $i <= 12; $n += $c[$i] * $b[$i++]);
23
24 12
        if ($c[13] != ((($n %= 11) < 2) ? 0 : 11 - $n)) {
25 1
            return false;
26
        }
27
28 11
        return true;
29
    }
30
}
31