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 — master (#802)
by
unknown
04:15
created

Pis   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 21
c 0
b 0
f 0
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B validate() 0 18 6
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 Pis extends AbstractRule
15
{
16 27
    public function validate($input)
17
    {
18 27
        $c = preg_replace('/\D/', '', $input);
19
20 27
        if (strlen($c) != 11 || preg_match("/^{$c[0]}{11}$/", $c)) {
21 10
            return false;
22
        }
23
24 17
        $r = [3,2,9,8,7,6,5,4,3,2];
25
26 17
        for ($n = 0, $i = 0; $i <= 9; $n += $c[$i] * $r[$i++]);
27
28 17
        if ($c[10] != ((($n %= 11) < 2) ? 0 : 11 - $n)) {
29 7
            return false;
30
        }
31
32 10
        return true;
33
    }
34
}
35