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 — 1.1 (#1036)
by Henrique
06:46
created

Bsn::validate()   A

Complexity

Conditions 5
Paths 6

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 10
cts 10
cp 1
rs 9.3888
c 0
b 0
f 0
cc 5
nc 6
nop 1
crap 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
/**
15
 * Validates a Dutch citizen service number (BSN).
16
 *
17
 * @author Ronald Drenth <[email protected]>
18
 *
19
 * @see https://nl.wikipedia.org/wiki/Burgerservicenummer
20
 */
21
class Bsn extends AbstractRule
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26 23
    public function validate($input)
27
    {
28 23
        if (!ctype_digit($input)) {
29 3
            return false;
30
        }
31
32 20
        if (strlen($input) !== 9) {
33 3
            return false;
34
        }
35
36 17
        $sum = -1 * $input[8];
37 17
        for ($i = 9; $i > 1; --$i) {
38 17
            $sum += $i * $input[9 - $i];
39 17
        }
40
41 17
        return $sum !== 0 && $sum % 11 === 0;
42
    }
43
}
44