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 — master ( 7b5a29...47eaea )
by Henrique
02:52
created

Cpf   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 9

1 Method

Rating   Name   Duplication   Size   Complexity  
C validate() 0 22 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
declare(strict_types=1);
13
14
namespace Respect\Validation\Rules;
15
16
class Cpf extends AbstractRule
17
{
18 22
    public function validate($input): bool
19
    {
20
        // Code ported from jsfromhell.com
21 22
        $c = preg_replace('/\D/', '', $input);
22
23 22
        if (11 != mb_strlen($c) || preg_match("/^{$c[0]}{11}$/", $c)) {
24 12
            return false;
25
        }
26
27 10
        for ($s = 10, $n = 0, $i = 0; $s >= 2; $n += $c[$i++] * $s--);
28
29 10
        if ($c[9] != ((($n %= 11) < 2) ? 0 : 11 - $n)) {
30 4
            return false;
31
        }
32
33 6
        for ($s = 11, $n = 0, $i = 0; $s >= 2; $n += $c[$i++] * $s--);
34
35 6
        if ($c[10] != ((($n %= 11) < 2) ? 0 : 11 - $n)) {
36 3
            return false;
37
        }
38
39 3
        return true;
40
    }
41
}
42