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

personalIdentityNumber on es_ES Person #408

Closed
wants to merge 2 commits into from
Closed
Changes from all 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
18 changes: 18 additions & 0 deletions src/Faker/Provider/es_ES/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,22 @@ public static function suffix()
{
return static::randomElement(static::$suffix);
}

/**
* National Personal Identity number (DNI/NIF)
*
* @return string on format 99999999X
*
* @url http://es.wikipedia.org/wiki/DNI_electr%C3%B3nico_en_Espa%C3%B1a
* @url http://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal
* @url http://bulma.net/body.phtml?nIdNoticia=2248
*/
public function personalIdentityNumber()
{
$number = mt_rand(100, 99999999);
$number = str_pad($number, 8, '0', STR_PAD_LEFT);
$letter = substr('TRWAGMYFPDXBNJZSQVHLCKE', $number % 23, 1);
Copy link
Owner

Choose a reason for hiding this comment

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

Why this order?


return $number . $letter;
}
}