Framework Update
This commit is contained in:
+14
-9
@@ -1,12 +1,8 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Respect/Validation.
|
||||
*
|
||||
* (c) Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE file
|
||||
* that was distributed with this source code.
|
||||
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
@@ -14,7 +10,10 @@ declare(strict_types=1);
|
||||
namespace Respect\Validation\Rules;
|
||||
|
||||
use function ctype_digit;
|
||||
use function intval;
|
||||
use function is_scalar;
|
||||
use function mb_strlen;
|
||||
use function strval;
|
||||
|
||||
/**
|
||||
* Validates a Dutch citizen service number (BSN).
|
||||
@@ -32,17 +31,23 @@ final class Bsn extends AbstractRule
|
||||
*/
|
||||
public function validate($input): bool
|
||||
{
|
||||
if (!is_scalar($input)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$input = (string) $input;
|
||||
|
||||
if (!ctype_digit($input)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mb_strlen($input) !== 9) {
|
||||
if (mb_strlen(strval($input)) !== 9) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sum = -1 * $input[8];
|
||||
$sum = -1 * intval($input[8]);
|
||||
for ($i = 9; $i > 1; --$i) {
|
||||
$sum += $i * $input[9 - $i];
|
||||
$sum += $i * intval($input[9 - $i]);
|
||||
}
|
||||
|
||||
return $sum !== 0 && $sum % 11 === 0;
|
||||
|
||||
Reference in New Issue
Block a user