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 ( c951ce...0662db )
by Henrique
04:32
created

Pesel   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 0
cbo 1
dl 0
loc 24
ccs 13
cts 13
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B validate() 0 21 5
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 15
    public function validate($input)
17
    {
18 15
        if (!is_numeric($input)
19 15
            || !filter_var($input, FILTER_VALIDATE_INT)
20 15
            || strlen($input) != 11) {
21 6
            return false;
22
        }
23
24 9
        $weights = [1, 3, 7, 9, 1, 3, 7, 9, 1, 3];
25
26 9
        $targetControlNumber = $input[10];
27 9
        $calculateControlNumber = 0;
28
29 9
        for ($i = 0; $i < 10; $i++) {
30 9
            $calculateControlNumber += $input[$i] * $weights[$i];
31 9
        }
32
33 9
        $calculateControlNumber = (10 - $calculateControlNumber % 10) % 10;
34
35 9
        return $targetControlNumber == $calculateControlNumber;
36
    }
37
}
38