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:45
created

Pis::validate()   B

Complexity

Conditions 6
Paths 5

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 18
c 0
b 0
f 0
ccs 9
cts 9
cp 1
rs 8.8571
cc 6
eloc 9
nc 5
nop 1
crap 6
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * For the full copyright and license information, please view the "LICENSE.md"
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Respect\Validation\Rules;
11
12
class Pis extends AbstractRule
13
{
14 27
    public function validate($input)
15
    {
16 27
        $c = preg_replace('/\D/', '', $input);
17
18 27
        if (strlen($c) != 11 || preg_match("/^{$c[0]}{11}$/", $c)) {
19 10
            return false;
20
        }
21
22 17
        $r = [3,2,9,8,7,6,5,4,3,2];
23
24 17
        for ($n = 0, $i = 0; $i <= 9; $n += $c[$i] * $r[$i++]);
25
26 17
        if ($c[10] != ((($n %= 11) < 2) ? 0 : 11 - $n)) {
27 4
            return false;
28
        }
29
30 13
        return true;
31
    }
32
}
33