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

Chancing to personal fictitious numbers sv_SE #1457

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
14 changes: 11 additions & 3 deletions src/Faker/Provider/sv_SE/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ class Person extends \Faker\Provider\Person

/**
* National Personal Identity number (personnummer)
* For example, a number of social security numbers are used in training databases
* within the Swedish Tax Agency and for testing of IT systems and can
* therefore not given to people. This applies, for example, to social security number i
* series 980-999. It has been known in society that social security number in
* These series are usually not given to people. These social security numbers
* has therefore traditionally been used as fictitious numbers in the IT systems
* in various businesses and in advertising.
* Considering GDPR, introduced soon, one should use fictitious numbers
* @link http://en.wikipedia.org/wiki/Personal_identity_number_(Sweden)
* @param \DateTime $birthdate
* @param string $gender Person::GENDER_MALE || Person::GENDER_FEMALE
Expand All @@ -128,11 +136,11 @@ public function personalIdentityNumber(\DateTime $birthdate = null, $gender = nu
$datePart = $birthdate->format('ymd');

if ($gender && $gender == static::GENDER_MALE) {
$randomDigits = (string)static::numerify('##') . static::randomElement(array(1,3,5,7,9));
$randomDigits = (string)static::numberBetween(98, 99) . static::randomElement(array(1,3,5,7,9));
} elseif ($gender && $gender == static::GENDER_FEMALE) {
$randomDigits = (string)static::numerify('##') . static::randomElement(array(0,2,4,6,8));
$randomDigits = (string)static::numberBetween(98, 99) . static::randomElement(array(0,2,4,6,8));
} else {
$randomDigits = (string)static::numerify('###');
$randomDigits = (string)static::numberBetween(980, 999);
}


Expand Down
10 changes: 5 additions & 5 deletions test/Faker/Provider/sv_SE/PersonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public function setUp()
public function provideSeedAndExpectedReturn()
{
return array(
array(1, '720727', '720727-5798'),
array(2, '710414', '710414-5664'),
array(3, '591012', '591012-4519'),
array(4, '180307', '180307-0356'),
array(5, '820904', '820904-7748')
array(1, '720727', '720727-9915'),
array(2, '710414', '710414-9914'),
array(3, '591012', '591012-9898'),
array(4, '180307', '180307-9803'),
array(5, '820904', '820904-9959')
);
}

Expand Down