From fc57d06bf01f174709edc1bb796fe4e46bf1e212 Mon Sep 17 00:00:00 2001 From: Ingvar Kreft Date: Mon, 26 Mar 2018 16:04:28 +0200 Subject: [PATCH 1/3] Chancing to personal fictitious numbers --- src/Faker/Provider/sv_SE/Person.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Faker/Provider/sv_SE/Person.php b/src/Faker/Provider/sv_SE/Person.php index 2f1c67eea2..094acb98e3 100644 --- a/src/Faker/Provider/sv_SE/Person.php +++ b/src/Faker/Provider/sv_SE/Person.php @@ -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 @@ -128,16 +136,15 @@ 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); } $checksum = Luhn::computeCheckDigit($datePart . $randomDigits); return $datePart . '-' . $randomDigits . $checksum; - } -} + }} From 53b96a9c6061a4496dc89324f4a9402f88824e3e Mon Sep 17 00:00:00 2001 From: Ingvar Kreft Date: Mon, 26 Mar 2018 16:18:26 +0200 Subject: [PATCH 2/3] Update provide and seed array --- test/Faker/Provider/sv_SE/PersonTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/Faker/Provider/sv_SE/PersonTest.php b/test/Faker/Provider/sv_SE/PersonTest.php index 584998da9f..030c7f2fae 100644 --- a/test/Faker/Provider/sv_SE/PersonTest.php +++ b/test/Faker/Provider/sv_SE/PersonTest.php @@ -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') ); } From c2ab62588c1af66f1cde517b51c6771227c496f8 Mon Sep 17 00:00:00 2001 From: Ingvar Kreft Date: Mon, 26 Mar 2018 16:32:40 +0200 Subject: [PATCH 3/3] Fix code style --- src/Faker/Provider/sv_SE/Person.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Faker/Provider/sv_SE/Person.php b/src/Faker/Provider/sv_SE/Person.php index 094acb98e3..bd4d3c3ee9 100644 --- a/src/Faker/Provider/sv_SE/Person.php +++ b/src/Faker/Provider/sv_SE/Person.php @@ -147,4 +147,5 @@ public function personalIdentityNumber(\DateTime $birthdate = null, $gender = nu $checksum = Luhn::computeCheckDigit($datePart . $randomDigits); return $datePart . '-' . $randomDigits . $checksum; - }} + } +}