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

Cpf::validate()   C

Complexity

Conditions 9
Paths 11

Size

Total Lines 23
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 9

Importance

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