Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Added idNumber for nl_NL #1283

Merged
merged 7 commits into from
Aug 30, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/Faker/Provider/nl_NL/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,33 @@ public static function prefix()
{
return static::randomElement(static::$prefix);
}

/**
* 11 proof idNumber
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a @link annotation to a Wikipedia-like description of this id number, and of the algo you used here.

* @return string
*/
public function idNumber()
{
$return = '';
$nr = [];
$nr[] = 0;
while(count($nr) < 8) {
$nr[] = rand(0,9);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never use rand() in Faker, use mt_rand() instead. And if you want to generate a random digit, use randomDigit instead. Same on line 330

}
$nr[] = rand(0,6);
if( $nr[7]==0 && $nr[8]==0) $nr[7]=0;

$bsn = (9*$nr[8]) + (8*$nr[7]) + (7*$nr[6]) + (6*$nr[5]) + (5*$nr[4]) + (4*$nr[3]) + (3*$nr[2]) + (2*$nr[1]);
$nr[0] = floor($bsn-floor($bsn/11) * 11);
if( $nr[0] > 9) {
if( $nr[1]>0) {
$nr[0]=8;
$nr[1]--;
} else {
$nr[0]=1;
$nr[1]++;

}
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing return ?

}