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

add DNI generator to spanis person #763

Merged
merged 3 commits into from
Feb 23, 2016
Merged
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions src/Faker/Provider/es_ES/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

class Person extends \Faker\Provider\Person
{
private static $letters=array('T', 'R', 'W', 'A', 'G', 'M', 'Y', 'F', 'P', 'D', 'X', 'B', 'N', 'J', 'Z', 'S', 'Q', 'V', 'H', 'L', 'C', 'K', 'E', 'T');
Copy link
Owner

Choose a reason for hiding this comment

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

letters is a too specific name. Please rename it to make it obvious that this relates to DNI validation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe crcMap?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fzaninotto is it better now?


protected static $maleNameFormats = array(
'{{firstNameMale}} {{lastName}}',
'{{firstNameMale}} {{lastName}}',
Expand Down Expand Up @@ -68,4 +70,12 @@ public static function suffix()
{
return static::randomElement(static::$suffix);
}

public static function dni()
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 to the dni specification

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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 it as a @link annotation in the method phpDoc

{
$number=static::numerify('########');

$letter=self::$letters[$number%23];
return $number.$letter;
}
}