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 (#632)
by Henrique
10:34 queued 06:07
created

PlIdentityCard   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 93.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 27
ccs 14
cts 15
cp 0.9333
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C validate() 0 24 8
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\Locale;
13
14
use Respect\Validation\Rules\AbstractRule;
15
16
/**
17
 * Validator for Polish identity card.
18
 *
19
 * @link https://en.wikipedia.org/wiki/Polish_identity_card
20
 */
21
class PlIdentityCard extends AbstractRule
22
{
23 7
    public function validate($input)
24
    {
25 7
        $weights = [7, 3, 1, 0, 7, 3, 1, 7, 3];
26 7
        if (!preg_match('/^[A-Z0-9]{9}$/', $input)) {
27 1
            return false;
28
        }
29
30 6
        $controlNumber = 0;
31 6
        for ($i = 0; $i < 9; ++$i) {
32 6
            $value = ord($input[$i]);
33 6
            if ($i < 3 && $value <= 57) {
34
                return false;
35
            }
36
37 6
            if ($i > 2 && $value >= 65) {
38 1
                return false;
39
            }
40
41 6
            $difference = $value <= 57 ? 48 : 55; // ASCII: "0" is 48 and "A" is 65
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
42 6
            $controlNumber += ($value - $difference) * $weights[$i];
43 6
        }
44
45 5
        return $controlNumber % 10 == $input[3];
46
    }
47
}
48