Passed
Push — master ( 402f33...7c44c5 )
by Pol
02:04
created

BelgianNationalNumber   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 16
ccs 4
cts 4
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A belgianNationalIdentificationNumber() 0 7 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace drupol\BelgianNationalNumberFaker\Provider;
6
7
use drupol\BelgianNationalNumberFaker\Validator\BelgianNationalNumberValidator;
8
use Faker\Provider\Base;
9
use Faker\Provider\DateTime;
10
11
/**
12
 * Class BelgianNationalNumber.
13
 */
14
final class BelgianNationalNumber extends Base
15
{
16
    /**
17
     * Generate a random Belgian National Number.
18
     *
19
     * @return string
20
     *
21
     * @see https://en.wikipedia.org/wiki/National_identification_number
22
     */
23 1
    public function belgianNationalIdentificationNumber(): string
24
    {
25
        do {
26 1
            $probe = \mb_substr(DateTime::date('Ymd'), 2) . static::randomNumber(5, true);
27 1
        } while (false === BelgianNationalNumberValidator::isValid($probe));
28
29 1
        return $probe;
30
    }
31
}
32