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

Cpf   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

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