diff --git a/src/Faker/Provider/pl_PL/Address.php b/src/Faker/Provider/pl_PL/Address.php index 5cab0a95..9a945b78 100644 --- a/src/Faker/Provider/pl_PL/Address.php +++ b/src/Faker/Provider/pl_PL/Address.php @@ -13,6 +13,9 @@ class Address extends \Faker\Provider\Address protected static $buildingNumber = array('##A', '##', '##A/##', '##/##'); protected static $postcode = array('##-###'); + /** + * @var array full list of Polish voivodeship + */ protected static $state = array( 'dolnośląskie','kujawsko-pomorskie','lubelskie','lubuskie','łódzkie','małopolskie','mazowieckie','opolskie','podkarpackie', 'podlaskie','pomorskie','śląskie','świętokrzyskie','warmińsko-mazurskie','wielkopolskie','zachodniopomorskie' @@ -20,6 +23,9 @@ class Address extends \Faker\Provider\Address protected static $country = array( 'Polska', ); + /** + * @var array 250 Polish cities with biggest number of streets. Extracted from data issued by the official public postal service of Poland. @link http://www.poczta-polska.pl/ + */ protected static $city = array( 'Warszawa','Kraków','Łódź','Poznań','Wrocław','Gdańsk','Szczecin','Bydgoszcz','Lublin','Bielsko-Biała','Częstochowa','Katowice','Białystok','Gdynia','Radom', 'Rzeszów','Gliwice','Kielce','Opole','Rybnik','Sosnowiec','Zabrze','Ruda Śląska','Jaworzno','Olsztyn','Zielona Góra','Bytom','Koszalin','Dąbrowa Górnicza', @@ -39,6 +45,9 @@ class Address extends \Faker\Provider\Address 'Kętrzyn','Ostróda','Bochnia','Jelcz-Laskowice','Ząbki','Września','Bielawa','Nowy Targ','Giżycko','Dzierżoniów','Myszków','Marylka','Czechowice-Dziedzice','Łowicz','Łomianki','Świebodzice', 'Świebodzin','Lubojenka','Lubliniec','Świecie','Lubartów','Lidzbark Warmiński','Świdnik','Pisz','Szczytno','Świdwin','Kozienice','Brodnica','Kościerzyna','Braniewo','Koło' ); + /** + * @var array 549 most common Polish street names. Extracted from data issued by the official public postal service of Poland. @link http://www.poczta-polska.pl/ + */ protected static $street = array( 'Kościuszki Tadeusza','Mickiewicza Adama','Szkolna','Dworcowa','Kolejowa','Sienkiewicza Henryka','Rynek','Warszawska','Wojska Polskiego','Żeromskiego Stefana', 'Polna','1 Maja','Ogrodowa','Pocztowa','Grunwaldzka','Kopernika Mikołaja','Leśna','Lipowa','Słowackiego Juliusza','Parkowa','Kościelna','Jagiellońska','Słoneczna', diff --git a/src/Faker/Provider/pl_PL/Person.php b/src/Faker/Provider/pl_PL/Person.php index 9c88db89..e6727e7e 100644 --- a/src/Faker/Provider/pl_PL/Person.php +++ b/src/Faker/Provider/pl_PL/Person.php @@ -53,13 +53,17 @@ class Person extends \Faker\Provider\Person } /** + * PESEL - Universal Electronic System for Registration of the Population + * @link http://en.wikipedia.org/wiki/PESEL * @param DateTime $birthdate * @param string $sex M for male or F for female + * @return string 11 digit number, like 44051401358 */ public static function pesel($birthdate = null, $sex = null) { - if ($birthdate === null) - $birthdate = new \DateTime(date('Y-m-d',mt_rand(strtotime('1800-01-0'), time()))); + if ($birthdate === null) { + $birthdate = \Faker\Provider\DateTime::dateTimeThisCentury(); + } $weights = array(1, 3, 7, 9, 1, 3, 7, 9, 1, 3); $length = count($weights); @@ -75,9 +79,9 @@ class Person extends \Faker\Provider\Person $result[$i] = static::randomDigit(); } if ($sex == "M") { - $b[$length - 1] |= 1; + $result[$length - 1] |= 1; } elseif ($sex == "F") { - $b[$length - 1] ^= 1; + $result[$length - 1] ^= 1; } $checksum = 0; for ($i = 0; $i < $length; $i++) { @@ -88,6 +92,11 @@ class Person extends \Faker\Provider\Person return implode('',$result); } + /** + * National Identity Card number + * @link http://en.wikipedia.org/wiki/Polish_National_Identity_Card + * @return string 3 letters and 6 digits, like ABA300000 + */ public static function personalIdentityNumber() { $range = str_split("ABCDEFGHIJKLMNPRSTUVWXYZ"); @@ -104,4 +113,30 @@ class Person extends \Faker\Provider\Person $checksum %= 10; return implode('',$low).$checksum.implode('',$high); } + + /** + * Taxpayer Identification Number (NIP in Polish) + * @link http://en.wikipedia.org/wiki/PESEL#Other_identifiers + * @link http://pl.wikipedia.org/wiki/NIP + * @return string 10 digit number + */ + public static function taxpayerIdentificationNumber() + { + $weights = array(6, 5, 7, 2, 3, 4, 5, 6, 7); + $result = array(); + do { + $result = array( + static::randomDigitNotNull(), static::randomDigitNotNull(), static::randomDigitNotNull(), + static::randomDigit(), static::randomDigit(), static::randomDigit(), + static::randomDigit(), static::randomDigit(), static::randomDigit(), + ); + $checksum = 0; + for ($i = 0; $i < count($result); $i++) { + $checksum += $weights[$i] * $result[$i]; + } + $checksum %= 11; + } while ($checksum == 10); + $result[] = $checksum; + return implode('', $result); + } }