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 ( 8b7f48...d2c8b4 )
by Henrique
07:17
created

Pesel::validate()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 19
ccs 11
cts 11
cp 1
rs 9.4285
cc 3
eloc 10
nc 3
nop 1
crap 3
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 Pesel extends AbstractRule
15
{
16 17
    public function validate($input)
17
    {
18 17
        if (!preg_match('/^\d{11}$/', $input)) {
19 6
            return false;
20
        }
21
22 11
        $weights = [1, 3, 7, 9, 1, 3, 7, 9, 1, 3];
23
24 11
        $targetControlNumber = $input[10];
25 11
        $calculateControlNumber = 0;
26
27 11
        for ($i = 0; $i < 10; $i++) {
28 11
            $calculateControlNumber += $input[$i] * $weights[$i];
29 11
        }
30
31 11
        $calculateControlNumber = (10 - $calculateControlNumber % 10) % 10;
32
33 11
        return $targetControlNumber == $calculateControlNumber;
34
    }
35
}
36