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 (#1087)
by Henrique
11:00 queued 08:15
created

Bsn   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 8
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  
A isValid() 0 16 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
declare(strict_types=1);
13
14
namespace Respect\Validation\Rules;
15
16
use function ctype_digit;
17
use function mb_strlen;
18
19
/**
20
 * Validates a Dutch citizen service number (BSN).
21
 *
22
 * @see https://nl.wikipedia.org/wiki/Burgerservicenummer
23
 *
24
 * @author Henrique Moody <[email protected]>
25
 * @author Ronald Drenth <[email protected]>
26
 * @author William Espindola <[email protected]>
27
 */
28
final class Bsn extends AbstractRule
29
{
30
    /**
31
     * {@inheritdoc}
32
     */
33 27
    public function isValid($input): bool
34
    {
35 27
        if (!ctype_digit($input)) {
36 6
            return false;
37
        }
38
39 22
        if (9 !== mb_strlen($input)) {
40 3
            return false;
41
        }
42
43 19
        $sum = -1 * $input[8];
44 19
        for ($i = 9; $i > 1; --$i) {
45 19
            $sum += $i * $input[9 - $i];
46
        }
47
48 19
        return 0 !== $sum && 0 === $sum % 11;
49
    }
50
}
51