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::validate()   B

Complexity

Conditions 9
Paths 11

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 9

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 8.0555
c 0
b 0
f 0
cc 9
nc 11
nop 1
crap 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