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
Push — 1.1 ( fca464...0e73bc )
by Henrique
09:36 queued 06:14
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 0
Metric Value
wmc 9
lcom 0
cbo 1
dl 0
loc 26
c 0
b 0
f 0
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B validate() 0 23 9
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * (c) Alexandre Gomes Gaigalas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the "LICENSE.md"
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Respect\Validation\Rules;
13
14
class Cpf extends AbstractRule
15
{
16 27
    public function validate($input)
17
    {
18
        // Code ported from jsfromhell.com
19 27
        $c = preg_replace('/\D/', '', $input);
20
21 27
        if (strlen($c) != 11 || preg_match("/^{$c[0]}{11}$/", $c)) {
22 10
            return false;
23
        }
24
25 17
        for ($s = 10, $n = 0, $i = 0; $s >= 2; $n += $c[$i++] * $s--);
26
27 17
        if ($c[9] != ((($n %= 11) < 2) ? 0 : 11 - $n)) {
28 4
            return false;
29
        }
30
31 13
        for ($s = 11, $n = 0, $i = 0; $s >= 2; $n += $c[$i++] * $s--);
32
33 13
        if ($c[10] != ((($n %= 11) < 2) ? 0 : 11 - $n)) {
34 3
            return false;
35
        }
36
37 10
        return true;
38
    }
39
}
40