From ac9a5efb6bd9aec7e6b088a563f3e9b9a0ca746f Mon Sep 17 00:00:00 2001 From: Uzziel Date: Sun, 27 Oct 2019 01:33:40 +0300 Subject: [PATCH 1/5] Add new provider en_KE and generate classes --- src/Faker/Provider/en_KE/Address.php | 8 ++++++++ src/Faker/Provider/en_KE/Internet.php | 8 ++++++++ src/Faker/Provider/en_KE/Person.php | 8 ++++++++ src/Faker/Provider/en_KE/PhoneNumber.php | 8 ++++++++ 4 files changed, 32 insertions(+) create mode 100644 src/Faker/Provider/en_KE/Address.php create mode 100644 src/Faker/Provider/en_KE/Internet.php create mode 100644 src/Faker/Provider/en_KE/Person.php create mode 100644 src/Faker/Provider/en_KE/PhoneNumber.php diff --git a/src/Faker/Provider/en_KE/Address.php b/src/Faker/Provider/en_KE/Address.php new file mode 100644 index 0000000000..04c5d0b1de --- /dev/null +++ b/src/Faker/Provider/en_KE/Address.php @@ -0,0 +1,8 @@ + Date: Mon, 28 Oct 2019 17:27:22 +0300 Subject: [PATCH 2/5] Initial class update --- src/Faker/Provider/en_KE/Address.php | 178 +++++++++++++++++- src/Faker/Provider/en_KE/Internet.php | 5 + src/Faker/Provider/en_KE/Person.php | 76 ++++++++ src/Faker/Provider/en_KE/PhoneNumber.php | 82 +++++++- test/Faker/Provider/en_KE/AddressTest.php | 89 +++++++++ test/Faker/Provider/en_KE/InternetTest.php | 31 +++ test/Faker/Provider/en_KE/PersonTest.php | 55 ++++++ test/Faker/Provider/en_KE/PhoneNumberTest.php | 64 +++++++ 8 files changed, 578 insertions(+), 2 deletions(-) create mode 100644 test/Faker/Provider/en_KE/AddressTest.php create mode 100644 test/Faker/Provider/en_KE/InternetTest.php create mode 100644 test/Faker/Provider/en_KE/PersonTest.php create mode 100644 test/Faker/Provider/en_KE/PhoneNumberTest.php diff --git a/src/Faker/Provider/en_KE/Address.php b/src/Faker/Provider/en_KE/Address.php index 04c5d0b1de..be6cacc602 100644 --- a/src/Faker/Provider/en_KE/Address.php +++ b/src/Faker/Provider/en_KE/Address.php @@ -2,7 +2,183 @@ namespace Faker\Provider\en_KE; -class Address extends \Faker\Provider\en_US\Address +class Address extends \Faker\Provider\Address { + protected static $cityFormats = array( + '{{cityName}}', + ); + + /** + * Kenyan cities + */ + protected static $city = array('Nairobi','Mombasa','Kisumu'); + + /** + * Counties found in Kenya + * @see https://en.wikipedia.org/wiki/List_of_cities_and_towns_in_Kenya_by_population + */ + protected static $county = array( + + 'Baringo','Bomet','Bungoma','Busia','Elgeyo-marakwet', + 'Embu','Garissa','Homabay','Isiolo','Kajiado','Kakamega', + 'Kericho','Kiambu','Kilifi','Kirinyaga','Kisii','Kisumu', + 'Kitui','Kwale','Laikipia','Lamu','Machakos','Makueni', + 'Mandera','Marsabit','Meru','Migori','Mombasa','Murang\'a', + 'Nairobi','Nakuru','Nandi','Narok','Nyamira','Nyandarua', + 'Nyeri','Samburu','Siaya','Taita Taveta','Tana River', + 'Tharaka-Nithi','Trans-Nzoia','Turkana','Uasin Gishu', + 'Vihiga','Wajir','West Pokot', + ); + + /** + * Municipalities in Kenya + * @see https://en.wikipedia.org/wiki/List_of_cities_and_towns_in_Kenya_by_population + */ + protected static $municipality = array( + + 'Nakuru','Eldoret','Kehancha','Ruiru','Malindi','Naivasha', + 'Kitui','Machakos','Thika','Athi River (Mavoko)','Nyeri', + 'Vihiga','Wote','Mumias','Bomet','Kitale','Limuru','Kericho', + 'Kimilili','Kakamega','Kapsabet','Kiambu','Kisii','Bungoma', + 'Webuye','Busia','Runyenjes','Migori','Embu','Homabay','Lodwar', + 'Meru','Nyahururu','Nanyuki','Maua','Voi','Siaya','Chuka', + 'Kerugoya / Kutus', + ); + + protected static $country = array( + 'Afghanistan', 'Albania', 'Algeria', 'American Samoa', 'Andorra', + 'Angola', 'Anguilla', 'Antarctica (the territory South of 60 deg S)', + 'Antigua and Barbuda', 'Argentina', 'Armenia', 'Aruba', 'Australia', + 'Austria', 'Azerbaijan','Bahamas', 'Bahrain', 'Bangladesh', 'Barbados', + 'Belarus', 'Belgium', 'Belize', 'Benin', 'Bermuda', 'Bhutan', 'Bolivia', + 'Bosnia and Herzegovina', 'Botswana', 'Bouvet Island (Bouvetoya)', + 'Brazil', 'British Indian Ocean Territory (Chagos Archipelago)', + 'British Virgin Islands', 'Brunei Darussalam', 'Bulgaria', 'Burkina Faso', + 'Burundi','Cambodia', 'Cameroon', 'Canada', 'Cape Verde', 'Cayman Islands', + 'Central African Republic', 'Chad', 'Chile', 'China', 'Christmas Island', + 'Cocos (Keeling) Islands', 'Colombia', 'Comoros', 'Congo', 'Congo', + 'Cook Islands', 'Costa Rica', 'Cote d\'Ivoire', 'Croatia', 'Cuba', 'Cyprus', + 'Czech Republic','Denmark', 'Djibouti', 'Dominica', 'Dominican Republic', + 'Ecuador', 'Egypt', 'El Salvador', 'Equatorial Guinea', 'Eritrea', 'Estonia', 'Ethiopia', + 'Faroe Islands', 'Falkland Islands (Malvinas)', 'Fiji', 'Finland', 'France', 'French Guiana', 'French Polynesia', + 'French Southern Territories','Gabon', 'Gambia', 'Georgia', 'Germany', 'Ghana', 'Gibraltar', 'Greece', + 'Greenland','Grenada', 'Guadeloupe', 'Guam', 'Guatemala', 'Guernsey', 'Guinea', 'Guinea-Bissau', 'Guyana', + 'Haiti', 'Heard Island and McDonald Islands', 'Holy See (Vatican City State)', 'Honduras', 'Hong Kong', + 'Hungary','Iceland', 'India', 'Indonesia', 'Iran', 'Iraq', 'Ireland', 'Isle of Man', 'Israel', 'Italy', + 'Jamaica', 'Japan', 'Jersey', 'Jordan','Kazakhstan', 'Kenya', 'Kiribati', 'Korea', 'Korea', + 'Kuwait', 'Kyrgyz Republic','Lao People\'s Democratic Republic', 'Latvia', 'Lebanon', 'Lesotho', 'Liberia', + 'Libyan Arab Jamahiriya', 'Liechtenstein', 'Lithuania', 'Luxembourg','Macao', + 'Macedonia', 'Madagascar', 'Malawi', 'Malaysia', 'Maldives', 'Mali', 'Malta', 'Marshall Islands', 'Martinique', + 'Mauritania', 'Mauritius', 'Mayotte', 'Mexico', 'Micronesia', 'Moldova', 'Monaco', 'Mongolia', 'Montenegro', + 'Montserrat', 'Morocco', 'Mozambique', 'Myanmar', + 'Namibia', 'Nauru', 'Nepal', 'Netherlands Antilles', 'Netherlands', 'New Caledonia', 'New Zealand', 'Nicaragua', + 'Niger', 'Nigeria', 'Niue', 'Norfolk Island', 'Northern Mariana Islands', 'Norway','Oman', + 'Pakistan', 'Palau', 'Palestinian Territories', 'Panama', 'Papua New Guinea', 'Paraguay', 'Peru', 'Philippines', + 'Pitcairn Islands', 'Poland', 'Portugal', 'Puerto Rico','Qatar', + 'Reunion', 'Romania', 'Russian Federation', 'Rwanda', + 'Saint Barthelemy', 'Saint Helena', 'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Martin', + 'Saint Pierre and Miquelon', 'Saint Vincent and the Grenadines', 'Samoa', 'San Marino', 'Sao Tome and Principe', + 'Saudi Arabia', 'Senegal', 'Serbia', 'Seychelles', 'Sierra Leone', 'Singapore', 'Slovakia (Slovak Republic)', + 'Slovenia', 'Solomon Islands', 'Somalia', 'South Africa', 'South Georgia and the South Sandwich Islands', + 'Spain', 'Sri Lanka', 'Sudan', 'Suriname', 'Svalbard & Jan Mayen Islands', 'Swaziland', 'Sweden', 'Switzerland', + 'Syrian Arab Republic','Taiwan', 'Tajikistan', 'Tanzania', 'Thailand', 'Timor-Leste', 'Togo', 'Tokelau', + 'Tonga', 'Trinidad and Tobago', 'Tunisia', 'Turkey', 'Turkmenistan', 'Turks and Caicos Islands', 'Tuvalu', + 'Uganda', 'Ukraine', 'United Arab Emirates', 'United Kingdom', 'United States of America', + 'United States Minor Outlying Islands', 'United States Virgin Islands', 'Uruguay', 'Uzbekistan', + 'Vanuatu', 'Venezuela', 'Vietnam','Wallis and Futuna', 'Western Sahara','Yemen','Zambia', 'Zimbabwe' + ); + + /** + * Towns found in Kenya + * @see https://en.wikipedia.org/wiki/List_of_cities_and_towns_in_Kenya_by_population + */ + public static $town = array( + + 'Kikuyu','Kangundo - tala','Karuri','Kilifi','Garissa','Molo','Litein','Mariakani', + 'Mandera','Nyamira','Mwingi','Rongo','Ahero','Nandi Hills','Makuyu','Kapenguria', + 'Taveta','Narok','Ol-Kalou','Malaba','Mbita Point','Malava','Suneka','Ogembo', + 'Ukwala','Keroka','Matuu','Oyugis','Kipkelion','Luanda','Eldama Ravine','Nyansiongo', + 'Londiani','Iten / Tambach','Malakisi','Bondo','Maralal','Nambale','Tabaka','Muhoroni', + 'Ugunja','Yala','Rumuruti','Burnt Forest','Maragua','Kendu Bay', + ); + + /** + * Centers in Kenya + * @see https://en.wikipedia.org/wiki/List_of_cities_and_towns_in_Kenya_by_population + */ + public static $center = array( + + 'Ngong','Awasi','Wajir','Kakuma','Ukunda','Wundanyi','Kitengela','Mtwapa', + 'Isiolo','Juja','Ongata Rongai','Moyale','Gilgil' + ); + + /** + * Streets in Kenya (Partial list for Nairobi only) + */ + public static $street = array( + + 'Moi Avenue','Kenyatta Avenue','Haile Sellasie Avenue', + 'Muindi Mbingu Street','Tom Mboya Street','Ramesh Gautama Road','University Way', + 'Luthuli Avenue','River Road','Taveta Road','Nyerere Road', + 'Mombasa Road','Koinange Street','Parliament Road','Race Course Road','Lang\'ata Road', + 'Uhuru Highway','Mama Ngina Street','Biashara Street','Kijabe Street','Mamlaka Road','Dorobo Road', + 'Arboretum Drive','Kivemia Rd','State House Road','Lower State House Rd','Utalii Street','Loita Street', + 'Market Street','Njugu Lane','Banda Street','Posta Street','Kaunda Street','City Hall Way','Harambee Avenue', + 'Tumbo Avenue','Parliament Lane','Valley Road','Ragati Road','Chiromo Lane', + ); + + /** + * Get Counties in Kenya + * @example Kajiado + */ + public static function county() + { + return static::randomElement(static::$county); + } + + /** + * Get municipalities in Kenya + * @example Nakuru + */ + public static function municipality() + { + return static::randomElement(static::$municipality); + } + + /** + * Get towns in Kenya + * @example Garissa + */ + public static function town() + { + return static::randomElement(static::$town); + } + + /** + * Get street name in Kenya + * @example Moi Avenue + */ + public static function street() + { + return static::randomElement(static::$street); + } + + /** + * Get town centers in Kenya + * @example Kitengela + */ + public static function center() + { + return static::randomElement(static::$center); + } + + /** + * Get cities in Kenya + * @example Nairobi + */ + public static function cityName() + { + return static::randomElement(static::$city); + } } diff --git a/src/Faker/Provider/en_KE/Internet.php b/src/Faker/Provider/en_KE/Internet.php index 8568a32a50..674f755bf1 100644 --- a/src/Faker/Provider/en_KE/Internet.php +++ b/src/Faker/Provider/en_KE/Internet.php @@ -4,5 +4,10 @@ class Internet extends \Faker\Provider\Internet { + protected static $tld = array( + 'com','or.ke','co.ke','ne.ke','go.ke','ac.ke', + 'sc.ke','me.ke','mobi.ke','info.ke','net','org','biz', + 'info', + ); } diff --git a/src/Faker/Provider/en_KE/Person.php b/src/Faker/Provider/en_KE/Person.php index 8234e1c71b..09d1ff6c40 100644 --- a/src/Faker/Provider/en_KE/Person.php +++ b/src/Faker/Provider/en_KE/Person.php @@ -4,5 +4,81 @@ class Person extends \Faker\Provider\Person { + protected static $maleNameFormats = array( + '{{firstNameMale}} {{lastNameMale}}', + '{{firstNameMale}} {{firstNameMale}} {{lastNameMale}}' + ); + protected static $femaleNameFormats = array( + '{{firstNameFemale}} {{lastNameFemale}}', + '{{firstNameFemale}} {{firstNameFemale}} {{lastNameFemale}}' + ); + + /** + * Typical Kenyan male firstnames. + */ + protected static $firstNameMale = array( + 'Trevor','Martin','Abubakar','Ibrahim','Alex','Allan','Amos','Nicholas','Andrew','Bakadi', + 'Benson','Brian','Carlos','Teddy','Dancan','David','Dennis','Michael','Derrick','Deodre', + 'Barnaby','Isaac','Jackson','James','Jeff','John','George','Joshua','Jude','Juniour', + 'Cahill','Kevin','Johnstone','Kareem','Ryan','Brian','Leon','Lionel','Marvin','Emmanuel','Mark', + 'Peter','Joel','Micky','Joseph','William','Reagan','Samuel','Earnest','Justin','Philip','Paul', + 'Patrick','Fabian','Smith','Ramadhan','Santos','Shawn','Isaiah','Stephen','Stanley','Edwin','Maxwel', + 'Tony','Victor','Vincent','Wilson','Yusuf','Rasael','Parker', + ); + + /** + * First names for Kenyan Females + */ + protected static $firstNameFemale = array( + 'Mercy','Mary','Brenda','Angel','Frida','Rose','Anastacia','Margret','Tracey','Stacy','Agnes', + 'Carol','Judy','Sharon','Amina','Coleta','Honorata','Renalda','Matrona','Jamie','Nazarene','Tonia', + 'Azaria','Meda','Leyla','Purity','Ashley','Yvone','Nikki','Becky','Alice','Bella','Anna','Beryl','Aimee', + 'Betty','Bianca','Kate','Celestine','Cesh','Angie','Cynthia','Dokia','Doreen','Dokia','Dota','Eunice', + 'Eva','Faith','Favor','Hilda','Grace','Husna','Irene','Jane','Janet','Jenin','Joy','Joan','Kaila','Susan', + 'Kaitlan','Kokki','Lenah','Lynn', + ); + + /** + * Kenyan Female Last Names + */ + protected static $lastNameFemale = array( + 'Auma','Atieno','Mukhoya','Eshkumo','Nangila','Kananu','Ndinda','Muli','Mwende', + 'Wairimu','Wangui','Wambui','Waithera','Wangare','Chebet','Chelang\'at','Wacheke', + 'Sakimpa','Muthoni','Hadija','Amina','Taabu','Khamisi','Njeri','Njoki','Shiko', + 'Semiryan','Mwangela','Malemba','Matunda','Chepkoech','Chelimo','Jelimo','Jepling\'', + 'Radol','Ingavo','Ali','Mwajuma','Masitsa','Minayo','Ingutia','Kemunto','Nzano','Mukami', + 'Abuor','Akech','Chepkemoi','Jebitok','Akello','Wamuyu','Kadzo','Karea', + ); + + /** + * Kenyan Male Last Names + */ + protected static $lastNameMale = array( + + 'Njenga','Kibet','Maina','Bambanya','Charo','Wafula','Asero','Barasa','Vaati','Wanjohi', + 'Muinde','Mwikya','Kivanguli','Otieno','Okello','Okoth','Ouma','Kimani','Mwangi','Kipkurui', + 'Njuguna','Kipkoech','Njoroge','Matagari','Indiatsi','Shionzo','Shipalapala','Leshitin','Kipkut', + 'Lang\'at', 'Simel','Mwamburi','Mwadime','Poisa','Mwaisho','Mwasungia','Washala','Mwachofi', + 'Onyancha','Musedi','Omondi','Ochola','Gogo','Osundwa','Mutua','Mwiti','Khabelwa','Mutethia', + 'Agengo','Murage','Owino','Jatelo','Jalang\'o','Otoyo','Kiplimo','Kinuthia','Kariuki','Kaula', + ); + + /** + * Generate Kenyan Male Last Name + * @example Osundwa + */ + public static function lastNameMale() + { + return static::randomElement(static::$lastNameMale); + } + + /** + * Generate Kenyan Female Last Name + * @example Karea + */ + public static function lastNameFemale() + { + return static::randomElement(static::$lastNameFemale); + } } diff --git a/src/Faker/Provider/en_KE/PhoneNumber.php b/src/Faker/Provider/en_KE/PhoneNumber.php index 1286ecd16b..ed198c85c0 100644 --- a/src/Faker/Provider/en_KE/PhoneNumber.php +++ b/src/Faker/Provider/en_KE/PhoneNumber.php @@ -4,5 +4,85 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber { + protected static $formats = array( + '07########','+2547########', + ); -} + protected static $landline = array( + + '20#######','40#######','41#######','45#######','50#######','52#######','54#######' + ); + + protected static $safaricom = array( + + '070#######','071#######','072#######','079#######' + ); + + protected static $telkom = array('077#######'); + + protected static $airtel = array('0731######','0786######','0787######','0788######','0789######'); + + protected static $equitel = array('076#######'); + + protected static $faiba = array('0747######'); + + /** + * Get Kenyan telephone Landlines + * @example 203643631 + */ + + public function landline() + { + return static::numerify($this->generator->parse(static::randomElement(static::$landline))); + } + + /** + * Get Kenyan Safaricom Phone Numbers + * @example 0712345678 + */ + + public function safaricom() + { + return static::numerify($this->generator->parse(static::randomElement(static::$safaricom))); + } + + /** + * Get Kenyan Telkom Numbers + * @example 0770000000 + */ + + public function telkom() + { + return static::numerify($this->generator->parse(static::randomElement(static::$telkom))); + } + + /** + * Get Kenyan airtel numbers + * @example 0730000000 + */ + + public function airtel() + { + return static::numerify($this->generator->parse(static::randomElement(static::$airtel))); + } + + /** + * Get Kenyan Equitel Numbers + * @example 0763000000 + */ + + public function equitel() + { + return static::numerify($this->generator->parse(static::randomElement(static::$equitel))); + } + + /** + * Get Kenyan Faiba Numbers + * @example 0747000000 + */ + + public function faiba() + { + return static::numerify($this->generator->parse(static::randomElement(static::$faiba))); + } +} \ No newline at end of file diff --git a/test/Faker/Provider/en_KE/AddressTest.php b/test/Faker/Provider/en_KE/AddressTest.php new file mode 100644 index 0000000000..4a56bf9620 --- /dev/null +++ b/test/Faker/Provider/en_KE/AddressTest.php @@ -0,0 +1,89 @@ +addProvider(new Address($faker)); + $this->faker = $faker; + } + + public function testCity() + { + $city = $this->faker->city(); + $this->assertNotEmpty($city); + $this->assertInternalType('string', $city); + $this->assertRegExp('/[A-Z][a-z]+/', $city); + } + + public function testCountry() + { + $country = $this->faker->country(); + $this->assertNotEmpty($country); + $this->assertInternalType('string', $country); + $this->assertRegExp('/[A-Z][a-z]+/', $country); + } + + public function testMunicipality() + { + $municipality = $this->faker->municipality(); + $this->assertNotEmpty($municipality); + $this->assertInternalType('string', $municipality); + $this->assertRegExp('/[A-Z][a-z]+/',$municipality); + } + + public function testCounty() + { + $county = $this->faker->county(); + $this->assertNotEmpty($county); + $this->assertInternalType('string', $county); + $this->assertRegExp('/[A-Z][a-z]+/',$county); + } + + public function testTown() + { + $town = $this->faker->town(); + $this->assertNotEmpty($town); + $this->assertInternalType('string', $town); + $this->assertRegExp('/[A-Z][a-z]+/',$town); + } + + public function testCenter() + { + $center = $this->faker->center(); + $this->assertNotEmpty($center); + $this->assertInternalType('string', $center); + $this->assertRegExp('/[A-Z][a-z]+/',$center); + } + + public function testStreetName() + { + $street = $this->faker->street(); + $this->assertNotEmpty($street); + $this->assertInternalType('string', $street); + $this->assertRegExp('/[A-Z][a-z]+/',$street); + } + + public function testPostCode() + { + $code = $this->faker->postcode(); + $this->assertNotEmpty($code); + $this->assertInternalType('string', $code); + $this->assertRegExp('/[0-9]+/',$code); + } +} + +?> diff --git a/test/Faker/Provider/en_KE/InternetTest.php b/test/Faker/Provider/en_KE/InternetTest.php new file mode 100644 index 0000000000..052c368cc9 --- /dev/null +++ b/test/Faker/Provider/en_KE/InternetTest.php @@ -0,0 +1,31 @@ +addProvider(new Internet($faker)); + $this->faker = $faker; + } + + public function testTld() + { + $tld = $this->faker->tld(); + $this->assertNotEmpty($tld); + $this->assertInternalType('string', $tld); + $this->assertRegExp('/\w+(\.\w+)*$/', $tld); + } +} \ No newline at end of file diff --git a/test/Faker/Provider/en_KE/PersonTest.php b/test/Faker/Provider/en_KE/PersonTest.php new file mode 100644 index 0000000000..7e378e81ba --- /dev/null +++ b/test/Faker/Provider/en_KE/PersonTest.php @@ -0,0 +1,55 @@ +addProvider(new Person($faker)); + $this->faker = $faker; + } + + public function testFirstNameMale() + { + $name = $this->faker->firstNameMale(); + $this->assertNotEmpty($name); + $this->assertInternalType('string', $name); + $this->assertRegExp('/[A-Z][a-z]+/', $name); + } + + public function testFirstNameFemale() + { + $name = $this->faker->firstNameFemale(); + $this->assertNotEmpty($name); + $this->assertInternalType('string', $name); + $this->assertRegExp('/[A-Z][a-z]+/', $name); + } + + public function testLastNameMale() + { + $name = $this->faker->lastNameMale(); + $this->assertNotEmpty($name); + $this->assertInternalType('string', $name); + $this->assertRegExp('/[A-Z][a-z]+/', $name); + } + + public function testLastNameFemale() + { + $name = $this->faker->lastNameFemale(); + $this->assertNotEmpty($name); + $this->assertInternalType('string', $name); + $this->assertRegExp('/[A-Z][a-z]+/', $name); + } +} \ No newline at end of file diff --git a/test/Faker/Provider/en_KE/PhoneNumberTest.php b/test/Faker/Provider/en_KE/PhoneNumberTest.php new file mode 100644 index 0000000000..f6ea18c339 --- /dev/null +++ b/test/Faker/Provider/en_KE/PhoneNumberTest.php @@ -0,0 +1,64 @@ +addProvider(new PhoneNumber($faker)); + $this->faker = $faker; + } + + public function testPhoneNumber() + { + $phone = $this->faker->PhoneNumber(); + $this->assertNotEmpty($phone); + $this->assertInternalType('string', $phone); + $this->assertRegexp('/^(?:254|\+254|0)?(7(?:(?:[0-9][0-9])|(?:5[0-6])|([0-9][5-9]))[0-9]{6})$/',$phone); + } + + public function testSafaricom() + { + $phone = $this->faker->safaricom(); + $this->assertNotEmpty($phone); + $this->assertInternalType('string', $phone); + $this->assertRegexp('/^(?:254|\+254|0)?(7(?:(?:[12][0-9])|(?:0[0-9])|(9[0-9]))[0-9]{6})$/',$phone); + } + + public function testTelkom() + { + $phone = $this->faker->telkom(); + $this->assertNotEmpty($phone); + $this->assertInternalType('string', $phone); + $this->assertRegexp('/^(?:254|\+254|0)?(77[0-9][0-9]{6})$/',$phone); + } + + public function testAirtel() + { + $phone = $this->faker->airtel(); + $this->assertNotEmpty($phone); + $this->assertInternalType('string', $phone); + $this->assertRegexp('/^(?:254|\+254|0)?(7(?:(?:[3][0-9])|(?:5[0-6])|(8[5-9]))[0-9]{6})$/',$phone); + } + + public function testFaiba() + { + $phone = $this->faker->faiba(); + $this->assertNotEmpty($phone); + $this->assertInternalType('string', $phone); + $this->assertRegexp('/^(?:254|\+254|0)?(74[7][0-9]{6})$/',$phone); + } + +} From 9abdee85635e22b5d6c295a8ca320fed646bd3c1 Mon Sep 17 00:00:00 2001 From: Uzziel Date: Mon, 28 Oct 2019 23:47:55 +0300 Subject: [PATCH 3/5] Update data for random generation --- readme.md | 58 ++++++++++++++++++++++++ src/Faker/Provider/en_KE/Address.php | 6 ++- src/Faker/Provider/en_KE/Person.php | 42 +++++++++++++++-- src/Faker/Provider/en_KE/PhoneNumber.php | 5 +- 4 files changed, 103 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index 72a79b7f22..696ac90272 100644 --- a/readme.md +++ b/readme.md @@ -933,6 +933,64 @@ echo $faker->faxNumber; // "71937729" ``` +### `Faker\Provider\en_KE\Address` + +```php +town; // "Kikuyu" + +//Generate a random valid kenyan Center name +echo $faker->center; // "Kitengela" + +//Generate a valid random Kenyan Street Name +echo $faker->street; // "University Way" + +//Generate a valid random county name +echo $faker->county; // "Bomet" + +//Generate a valid random municipality name +echo $faker->municipality; // "Thika" +``` +### `Faker\Provider\en_KE\PhoneNumber` +```php +safaricom // "0701032617" + +//Generate random telkom number +echo $faker->telkom; // "0770589963" + +//Generate random airtel number +echo $faker->airtel; // "0739641523" + +//Generate random equitel number +echo $faker->equitel; // "0763915144" + +//Generate random faiba number +echo $faker->faiba; // "0747653231" + +//Generate a random landline number +echo $faker->landline; // "203532000" +``` +### `Faker\Provider\en_KE\Person` +```php +lastNameMale; // "Ochieng'" + +//Generate random last name for kenyan female +echo $faker->lastNameFemale; // "Njoki" + +//Generate random ID Number +echo $faker->idNumber; + +//Generate random valid KRA PIN +echo $faker->kraPin; +``` ### `Faker\Provider\en_NG\Address` ```php diff --git a/src/Faker/Provider/en_KE/Address.php b/src/Faker/Provider/en_KE/Address.php index be6cacc602..a264cd11b2 100644 --- a/src/Faker/Provider/en_KE/Address.php +++ b/src/Faker/Provider/en_KE/Address.php @@ -9,8 +9,12 @@ class Address extends \Faker\Provider\Address '{{cityName}}', ); + protected static $addressFormats = array( + 'P.O. BOX {{postcode}} {{county}}', + ); + /** - * Kenyan cities + * Kenya has got only three cities */ protected static $city = array('Nairobi','Mombasa','Kisumu'); diff --git a/src/Faker/Provider/en_KE/Person.php b/src/Faker/Provider/en_KE/Person.php index 09d1ff6c40..06e5c363b8 100644 --- a/src/Faker/Provider/en_KE/Person.php +++ b/src/Faker/Provider/en_KE/Person.php @@ -15,7 +15,8 @@ class Person extends \Faker\Provider\Person ); /** - * Typical Kenyan male firstnames. + * Typical Kenyan male firstnames + * @link */ protected static $firstNameMale = array( 'Trevor','Martin','Abubakar','Ibrahim','Alex','Allan','Amos','Nicholas','Andrew','Bakadi', @@ -29,6 +30,7 @@ class Person extends \Faker\Provider\Person /** * First names for Kenyan Females + * @link */ protected static $firstNameFemale = array( 'Mercy','Mary','Brenda','Angel','Frida','Rose','Anastacia','Margret','Tracey','Stacy','Agnes', @@ -41,6 +43,7 @@ class Person extends \Faker\Provider\Person /** * Kenyan Female Last Names + * @link */ protected static $lastNameFemale = array( 'Auma','Atieno','Mukhoya','Eshkumo','Nangila','Kananu','Ndinda','Muli','Mwende', @@ -53,6 +56,7 @@ class Person extends \Faker\Provider\Person /** * Kenyan Male Last Names + * @link */ protected static $lastNameMale = array( @@ -61,14 +65,24 @@ class Person extends \Faker\Provider\Person 'Njuguna','Kipkoech','Njoroge','Matagari','Indiatsi','Shionzo','Shipalapala','Leshitin','Kipkut', 'Lang\'at', 'Simel','Mwamburi','Mwadime','Poisa','Mwaisho','Mwasungia','Washala','Mwachofi', 'Onyancha','Musedi','Omondi','Ochola','Gogo','Osundwa','Mutua','Mwiti','Khabelwa','Mutethia', - 'Agengo','Murage','Owino','Jatelo','Jalang\'o','Otoyo','Kiplimo','Kinuthia','Kariuki','Kaula', + 'Agengo','Murage','Owino','Jatelo','Jalang\'o','Otoyo','Kiplimo','Kinuthia','Kariuki','Kaula','Ochieng\'', ); + /** + * ID Numbers of kenyans issued from 1970 - Present + */ + protected static $idNumber = array('8######','########'); + + /** + * Tax Payer PIN Number (KRA PIN) Format + */ + protected static $kraPin = array('?#########?'); + /** * Generate Kenyan Male Last Name * @example Osundwa */ - public static function lastNameMale() + public function lastNameMale() { return static::randomElement(static::$lastNameMale); } @@ -77,8 +91,26 @@ public static function lastNameMale() * Generate Kenyan Female Last Name * @example Karea */ - public static function lastNameFemale() + public function lastNameFemale() { return static::randomElement(static::$lastNameFemale); } -} + + /** + * Generate a valid Kenyan ID Number + * @example 01011101 + */ + public function idNumber() + { + return static::numerify($this->generator->parse(static::randomElement(static::$idNumber))); + } + + /** + * Generate a valid Kenyan KRA PIN + * @example Z001002321W + */ + public function kraPin() + { + return strtoupper(static::bothify($this->generator->parse(static::randomElement(static::$kraPin)))); + } +} \ No newline at end of file diff --git a/src/Faker/Provider/en_KE/PhoneNumber.php b/src/Faker/Provider/en_KE/PhoneNumber.php index ed198c85c0..73aae3b3c7 100644 --- a/src/Faker/Provider/en_KE/PhoneNumber.php +++ b/src/Faker/Provider/en_KE/PhoneNumber.php @@ -15,14 +15,15 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber protected static $safaricom = array( - '070#######','071#######','072#######','079#######' + '070#######','071#######','072#######','0740######', + '0741######','0742######','0748######','079#######', ); protected static $telkom = array('077#######'); protected static $airtel = array('0731######','0786######','0787######','0788######','0789######'); - protected static $equitel = array('076#######'); + protected static $equitel = array('0763######'); protected static $faiba = array('0747######'); From fbfc8d5d12a9efbf0f5981fa71a8d265fe8cc26c Mon Sep 17 00:00:00 2001 From: Uzziel Date: Tue, 29 Oct 2019 00:17:51 +0300 Subject: [PATCH 4/5] Minor fixes --- test/Faker/Provider/en_KE/AddressTest.php | 56 ------------------- test/Faker/Provider/en_KE/InternetTest.php | 31 ---------- test/Faker/Provider/en_KE/PersonTest.php | 55 ------------------ test/Faker/Provider/en_KE/PhoneNumberTest.php | 33 ----------- 4 files changed, 175 deletions(-) delete mode 100644 test/Faker/Provider/en_KE/InternetTest.php delete mode 100644 test/Faker/Provider/en_KE/PersonTest.php diff --git a/test/Faker/Provider/en_KE/AddressTest.php b/test/Faker/Provider/en_KE/AddressTest.php index 4a56bf9620..90a57d305b 100644 --- a/test/Faker/Provider/en_KE/AddressTest.php +++ b/test/Faker/Provider/en_KE/AddressTest.php @@ -28,62 +28,6 @@ public function testCity() $this->assertInternalType('string', $city); $this->assertRegExp('/[A-Z][a-z]+/', $city); } - - public function testCountry() - { - $country = $this->faker->country(); - $this->assertNotEmpty($country); - $this->assertInternalType('string', $country); - $this->assertRegExp('/[A-Z][a-z]+/', $country); - } - - public function testMunicipality() - { - $municipality = $this->faker->municipality(); - $this->assertNotEmpty($municipality); - $this->assertInternalType('string', $municipality); - $this->assertRegExp('/[A-Z][a-z]+/',$municipality); - } - - public function testCounty() - { - $county = $this->faker->county(); - $this->assertNotEmpty($county); - $this->assertInternalType('string', $county); - $this->assertRegExp('/[A-Z][a-z]+/',$county); - } - - public function testTown() - { - $town = $this->faker->town(); - $this->assertNotEmpty($town); - $this->assertInternalType('string', $town); - $this->assertRegExp('/[A-Z][a-z]+/',$town); - } - - public function testCenter() - { - $center = $this->faker->center(); - $this->assertNotEmpty($center); - $this->assertInternalType('string', $center); - $this->assertRegExp('/[A-Z][a-z]+/',$center); - } - - public function testStreetName() - { - $street = $this->faker->street(); - $this->assertNotEmpty($street); - $this->assertInternalType('string', $street); - $this->assertRegExp('/[A-Z][a-z]+/',$street); - } - - public function testPostCode() - { - $code = $this->faker->postcode(); - $this->assertNotEmpty($code); - $this->assertInternalType('string', $code); - $this->assertRegExp('/[0-9]+/',$code); - } } ?> diff --git a/test/Faker/Provider/en_KE/InternetTest.php b/test/Faker/Provider/en_KE/InternetTest.php deleted file mode 100644 index 052c368cc9..0000000000 --- a/test/Faker/Provider/en_KE/InternetTest.php +++ /dev/null @@ -1,31 +0,0 @@ -addProvider(new Internet($faker)); - $this->faker = $faker; - } - - public function testTld() - { - $tld = $this->faker->tld(); - $this->assertNotEmpty($tld); - $this->assertInternalType('string', $tld); - $this->assertRegExp('/\w+(\.\w+)*$/', $tld); - } -} \ No newline at end of file diff --git a/test/Faker/Provider/en_KE/PersonTest.php b/test/Faker/Provider/en_KE/PersonTest.php deleted file mode 100644 index 7e378e81ba..0000000000 --- a/test/Faker/Provider/en_KE/PersonTest.php +++ /dev/null @@ -1,55 +0,0 @@ -addProvider(new Person($faker)); - $this->faker = $faker; - } - - public function testFirstNameMale() - { - $name = $this->faker->firstNameMale(); - $this->assertNotEmpty($name); - $this->assertInternalType('string', $name); - $this->assertRegExp('/[A-Z][a-z]+/', $name); - } - - public function testFirstNameFemale() - { - $name = $this->faker->firstNameFemale(); - $this->assertNotEmpty($name); - $this->assertInternalType('string', $name); - $this->assertRegExp('/[A-Z][a-z]+/', $name); - } - - public function testLastNameMale() - { - $name = $this->faker->lastNameMale(); - $this->assertNotEmpty($name); - $this->assertInternalType('string', $name); - $this->assertRegExp('/[A-Z][a-z]+/', $name); - } - - public function testLastNameFemale() - { - $name = $this->faker->lastNameFemale(); - $this->assertNotEmpty($name); - $this->assertInternalType('string', $name); - $this->assertRegExp('/[A-Z][a-z]+/', $name); - } -} \ No newline at end of file diff --git a/test/Faker/Provider/en_KE/PhoneNumberTest.php b/test/Faker/Provider/en_KE/PhoneNumberTest.php index f6ea18c339..21b4b1e53c 100644 --- a/test/Faker/Provider/en_KE/PhoneNumberTest.php +++ b/test/Faker/Provider/en_KE/PhoneNumberTest.php @@ -28,37 +28,4 @@ public function testPhoneNumber() $this->assertInternalType('string', $phone); $this->assertRegexp('/^(?:254|\+254|0)?(7(?:(?:[0-9][0-9])|(?:5[0-6])|([0-9][5-9]))[0-9]{6})$/',$phone); } - - public function testSafaricom() - { - $phone = $this->faker->safaricom(); - $this->assertNotEmpty($phone); - $this->assertInternalType('string', $phone); - $this->assertRegexp('/^(?:254|\+254|0)?(7(?:(?:[12][0-9])|(?:0[0-9])|(9[0-9]))[0-9]{6})$/',$phone); - } - - public function testTelkom() - { - $phone = $this->faker->telkom(); - $this->assertNotEmpty($phone); - $this->assertInternalType('string', $phone); - $this->assertRegexp('/^(?:254|\+254|0)?(77[0-9][0-9]{6})$/',$phone); - } - - public function testAirtel() - { - $phone = $this->faker->airtel(); - $this->assertNotEmpty($phone); - $this->assertInternalType('string', $phone); - $this->assertRegexp('/^(?:254|\+254|0)?(7(?:(?:[3][0-9])|(?:5[0-6])|(8[5-9]))[0-9]{6})$/',$phone); - } - - public function testFaiba() - { - $phone = $this->faker->faiba(); - $this->assertNotEmpty($phone); - $this->assertInternalType('string', $phone); - $this->assertRegexp('/^(?:254|\+254|0)?(74[7][0-9]{6})$/',$phone); - } - } From cf158d75ced8b025bbe351ded275182bb7292cd9 Mon Sep 17 00:00:00 2001 From: Uzziel Date: Tue, 29 Oct 2019 00:55:20 +0300 Subject: [PATCH 5/5] Added @link pointing to names --- src/Faker/Provider/en_KE/Person.php | 18 +++++++++--------- src/Faker/Provider/en_KE/PhoneNumber.php | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Faker/Provider/en_KE/Person.php b/src/Faker/Provider/en_KE/Person.php index 06e5c363b8..90e5378a60 100644 --- a/src/Faker/Provider/en_KE/Person.php +++ b/src/Faker/Provider/en_KE/Person.php @@ -16,7 +16,7 @@ class Person extends \Faker\Provider\Person /** * Typical Kenyan male firstnames - * @link + * @link https://github.com/uzziellite/Faker/blob/master/src/Faker/Provider/en_KE/Person.php */ protected static $firstNameMale = array( 'Trevor','Martin','Abubakar','Ibrahim','Alex','Allan','Amos','Nicholas','Andrew','Bakadi', @@ -30,7 +30,7 @@ class Person extends \Faker\Provider\Person /** * First names for Kenyan Females - * @link + * @link https://github.com/uzziellite/Faker/blob/master/src/Faker/Provider/en_KE/Person.php */ protected static $firstNameFemale = array( 'Mercy','Mary','Brenda','Angel','Frida','Rose','Anastacia','Margret','Tracey','Stacy','Agnes', @@ -43,7 +43,7 @@ class Person extends \Faker\Provider\Person /** * Kenyan Female Last Names - * @link + * @link https://github.com/uzziellite/Faker/blob/master/src/Faker/Provider/en_KE/Person.php */ protected static $lastNameFemale = array( 'Auma','Atieno','Mukhoya','Eshkumo','Nangila','Kananu','Ndinda','Muli','Mwende', @@ -56,7 +56,7 @@ class Person extends \Faker\Provider\Person /** * Kenyan Male Last Names - * @link + * @link https://github.com/uzziellite/Faker/blob/master/src/Faker/Provider/en_KE/Person.php */ protected static $lastNameMale = array( @@ -84,7 +84,7 @@ class Person extends \Faker\Provider\Person */ public function lastNameMale() { - return static::randomElement(static::$lastNameMale); + return static::randomElement(static::$lastNameMale); } /** @@ -93,7 +93,7 @@ public function lastNameMale() */ public function lastNameFemale() { - return static::randomElement(static::$lastNameFemale); + return static::randomElement(static::$lastNameFemale); } /** @@ -102,7 +102,7 @@ public function lastNameFemale() */ public function idNumber() { - return static::numerify($this->generator->parse(static::randomElement(static::$idNumber))); + return static::numerify($this->generator->parse(static::randomElement(static::$idNumber))); } /** @@ -111,6 +111,6 @@ public function idNumber() */ public function kraPin() { - return strtoupper(static::bothify($this->generator->parse(static::randomElement(static::$kraPin)))); + return strtoupper(static::bothify($this->generator->parse(static::randomElement(static::$kraPin)))); } -} \ No newline at end of file +} diff --git a/src/Faker/Provider/en_KE/PhoneNumber.php b/src/Faker/Provider/en_KE/PhoneNumber.php index 73aae3b3c7..86be90e619 100644 --- a/src/Faker/Provider/en_KE/PhoneNumber.php +++ b/src/Faker/Provider/en_KE/PhoneNumber.php @@ -86,4 +86,4 @@ public function faiba() { return static::numerify($this->generator->parse(static::randomElement(static::$faiba))); } -} \ No newline at end of file +}