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

Commit

Permalink
Merge pull request #759 from smithandre/en-za-company
Browse files Browse the repository at this point in the history
* Added an en_ZA company provider, that can generate company registration numbers
  • Loading branch information
fzaninotto committed Oct 30, 2015
2 parents ffa4676 + ea7bd61 commit e0d369d
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 8 deletions.
9 changes: 9 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,15 @@ echo $faker->siren; // 082 250 104
echo $faker->siret; // 347 355 708 00224
```

### `Faker\Provider\en_ZA\Company`

```php
<?php

// Generates a random company registration number
echo $faker->companyNumber; // 1999/789634/01
```

### `Faker\Provider\fr_FR\Address`

```php
Expand Down
10 changes: 5 additions & 5 deletions src/Faker/Provider/en_ZA/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ class Address extends \Faker\Provider\Address
protected static $citySuffix = array('fontein','town', 'ton', 'land', 'ville', 'berg', 'burgh', 'borough', 'bury', 'view', 'port', 'mouth', 'stad', 'furt', 'chester', 'mouth', 'fort', 'haven', 'side', 'shire');
protected static $buildingNumber = array('#####', '####', '###');
protected static $streetSuffix = array(
'Alley', 'Avenue', 'Branch', 'Bridge', 'Brook', 'Brooks', 'Burg', 'Burgs', 'Bypass', 'Camp', 'Canyon', 'Cape', 'Causeway', 'Center', 'Centers', 'Circle', 'Circles', 'Cliff', 'Cliffs', 'Club', 'Common', 'Corner', 'Corners', 'Course', 'Court', 'Courts', 'Cove', 'Coves', 'Creek', 'Crescent', 'Crest', 'Crossing', 'Crossroad', 'Curve', 'Dale', 'Dam', 'Divide', 'Drive', 'Drive', 'Drives', 'Estate', 'Estates', 'Expressway', 'Extension', 'Extensions', 'Fall', 'Falls', 'Ferry', 'Field', 'Fields', 'Flat', 'Flats', 'Ford', 'Fords', 'Forest', 'Forge', 'Forges', 'Fork', 'Forks', 'Fort', 'Freeway', 'Garden', 'Gardens', 'Gateway', 'Glen', 'Glens', 'Green', 'Greens', 'Grove', 'Groves', 'Harbor', 'Harbors', 'Haven', 'Heights', 'Highway', 'Hill', 'Hills', 'Hollow', 'Inlet', 'Inlet', 'Island', 'Island', 'Islands', 'Islands', 'Isle', 'Isle', 'Junction', 'Junctions', 'Key', 'Keys', 'Knoll', 'Knolls', 'Lake', 'Lakes', 'Land', 'Landing', 'Lane', 'Light', 'Lights', 'Loaf', 'Lock', 'Locks', 'Locks', 'Lodge', 'Lodge', 'Loop', 'Mall', 'Manor', 'Manors', 'Meadow', 'Meadows', 'Mews', 'Mill', 'Mills', 'Mission', 'Mission', 'Motorway', 'Mount', 'Mountain', 'Mountain', 'Mountains', 'Mountains', 'Neck', 'Orchard', 'Oval', 'Overpass', 'Park', 'Parks', 'Parkway', 'Parkways', 'Pass', 'Passage', 'Path', 'Pike', 'Pine', 'Pines', 'Place', 'Plain', 'Plains', 'Plains', 'Plaza', 'Plaza', 'Point', 'Points', 'Port', 'Port', 'Ports', 'Ports', 'Prairie', 'Prairie', 'Radial', 'Ramp', 'Ranch', 'Rapid', 'Rapids', 'Rest', 'Ridge', 'Ridges', 'River', 'Road', 'Road', 'Roads', 'Roads', 'Route', 'Row', 'Rue', 'Run', 'Shoal', 'Shoals', 'Shore', 'Shores', 'Skyway', 'Spring', 'Springs', 'Springs', 'Spur', 'Spurs', 'Square', 'Square', 'Squares', 'Squares', 'Station', 'Station', 'Stravenue', 'Stravenue', 'Stream', 'Stream', 'Street', 'Street', 'Streets', 'Summit', 'Summit', 'Terrace', 'Throughway', 'Trace', 'Track', 'Trafficway', 'Trail', 'Trail', 'Tunnel', 'Tunnel', 'Turnpike', 'Turnpike', 'Underpass', 'Union', 'Unions', 'Valley', 'Valleys', 'Via', 'Viaduct', 'View', 'Views', 'Village', 'Village', 'Villages', 'Ville', 'Vista', 'Vista', 'Walk', 'Walks', 'Wall', 'Way', 'Ways', 'Well', 'Wells'
'Alley', 'Avenue', 'Branch', 'Bridge', 'Brook', 'Brooks', 'Burg', 'Burgs', 'Bypass', 'Camp', 'Canyon', 'Cape', 'Causeway', 'Center', 'Centers', 'Circle', 'Circles', 'Cliff', 'Cliffs', 'Club', 'Common', 'Corner', 'Corners', 'Course', 'Court', 'Courts', 'Cove', 'Coves', 'Creek', 'Crescent', 'Crest', 'Crossing', 'Crossroad', 'Curve', 'Dale', 'Dam', 'Divide', 'Drive', 'Drive', 'Drives', 'Estate', 'Estates', 'Expressway', 'Extension', 'Extensions', 'Fall', 'Falls', 'Ferry', 'Field', 'Fields', 'Flat', 'Flats', 'Ford', 'Fords', 'Forest', 'Forge', 'Forges', 'Fork', 'Forks', 'Fort', 'Freeway', 'Garden', 'Gardens', 'Gateway', 'Glen', 'Glens', 'Green', 'Greens', 'Grove', 'Groves', 'Harbor', 'Harbors', 'Haven', 'Heights', 'Highway', 'Hill', 'Hills', 'Hollow', 'Inlet', 'Inlet', 'Island', 'Island', 'Islands', 'Islands', 'Isle', 'Isle', 'Junction', 'Junctions', 'Key', 'Keys', 'Knoll', 'Knolls', 'Lake', 'Lakes', 'Land', 'Landing', 'Lane', 'Light', 'Lights', 'Loaf', 'Lock', 'Locks', 'Locks', 'Lodge', 'Lodge', 'Loop', 'Mall', 'Manor', 'Manors', 'Meadow', 'Meadows', 'Mews', 'Mill', 'Mills', 'Mission', 'Mission', 'Motorway', 'Mount', 'Mountain', 'Mountain', 'Mountains', 'Mountains', 'Neck', 'Orchard', 'Oval', 'Overpass', 'Park', 'Parks', 'Parkway', 'Parkways', 'Pass', 'Passage', 'Path', 'Pike', 'Pine', 'Pines', 'Place', 'Plain', 'Plains', 'Plains', 'Plaza', 'Plaza', 'Point', 'Points', 'Port', 'Port', 'Ports', 'Ports', 'Prairie', 'Prairie', 'Radial', 'Ramp', 'Ranch', 'Rapid', 'Rapids', 'Rest', 'Ridge', 'Ridges', 'River', 'Road', 'Road', 'Roads', 'Roads', 'Route', 'Row', 'Rue', 'Run', 'Shoal', 'Shoals', 'Shore', 'Shores', 'Skyway', 'Spring', 'Springs', 'Springs', 'Spur', 'Spurs', 'Square', 'Square', 'Squares', 'Squares', 'Station', 'Station', 'Stravenue', 'Stravenue', 'Stream', 'Stream', 'Street', 'Street', 'Streets', 'Summit', 'Summit', 'Terrace', 'Throughway', 'Trace', 'Track', 'Trafficway', 'Trail', 'Trail', 'Tunnel', 'Tunnel', 'Turnpike', 'Turnpike', 'Underpass', 'Union', 'Unions', 'Valley', 'Valleys', 'Via', 'Viaduct', 'View', 'Views', 'Village', 'Village', 'Villages', 'Ville', 'Vista', 'Vista', 'Walk', 'Walks', 'Wall', 'Way', 'Ways', 'Well', 'Wells',
);
protected static $postcode = array('####');
protected static $province = array(
'Eastern Cape', 'Free State', 'Gauteng', 'KwaZulu-Natal', 'Limpopo', 'Mpumalanga', 'North-West', 'Northern Cape', 'Western Cape'
'Eastern Cape', 'Free State', 'Gauteng', 'KwaZulu-Natal', 'Limpopo', 'Mpumalanga', 'North-West', 'Northern Cape', 'Western Cape',
);
protected static $provinceAbbr = array(
'EC', 'FS', 'GP', 'KZN', 'LP', 'MP', 'NW', 'NC', 'WC'
'EC', 'FS', 'GP', 'KZN', 'LP', 'MP', 'NW', 'NC', 'WC',
);
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',
Expand All @@ -42,7 +42,7 @@ class Address extends \Faker\Provider\Address
'Vanuatu', 'Venezuela', 'Vietnam',
'Wallis and Futuna', 'Western Sahara',
'Yemen',
'Zambia', 'Zimbabwe'
'Zambia', 'Zimbabwe',
);
protected static $cityFormats = array(
'{{cityPrefix}} {{firstName}}{{citySuffix}}',
Expand All @@ -52,7 +52,7 @@ class Address extends \Faker\Provider\Address
);
protected static $streetNameFormats = array(
'{{firstName}} {{streetSuffix}}',
'{{lastName}} {{streetSuffix}}'
'{{lastName}} {{streetSuffix}}',
);
protected static $streetAddressFormats = array(
'{{buildingNumber}} {{streetName}}',
Expand Down
29 changes: 29 additions & 0 deletions src/Faker/Provider/en_ZA/Company.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Faker\Provider\en_ZA;

/**
* Class Company.
*/
class Company extends \Faker\Provider\Company
{
protected static $legalEntities = array(
'01', '02', '06', '07', '08', '09', '10', '11', '12', '14', '15', '16', '17', '20', '21', '22', '23', '24', '25',
'26', '30', '31', '80',
);

/**
* Return a valid company registration number.
*
* @return string
*/
public function companyNumber()
{
return sprintf(
'%s/%s/%s',
\Faker\Provider\DateTime::dateTimeBetween('-50 years', 'now')->format('Y'),
static::randomNumber(6, true),
static::randomElement(static::$legalEntities)
);
}
}
4 changes: 2 additions & 2 deletions src/Faker/Provider/en_ZA/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Person extends \Faker\Provider\Person
'{{titleFemale}} {{$firstNameFemale}} {{lastName}}',
);

protected static $firstNameMale =array(
protected static $firstNameMale = array(
'Abraham', 'Adriaan', 'Adrian', 'Ahmed', 'Alan', 'Albert', 'Alex', 'Alexander', 'Alfred', 'Allan', 'Andile', 'Andre', 'Andrew',
'André', 'Anthony', 'Anton', 'Arnold', 'Arthur', 'Ayanda', 'Barry', 'Ben', 'Benjamin', 'Bernard', 'Bongani', 'Bradley',
'Brandon', 'Brent', 'Brett', 'Brian', 'Bruce', 'Bryan', 'Carel', 'Carl', 'Charl', 'Charles', 'Chris', 'Christiaan',
Expand Down Expand Up @@ -121,6 +121,6 @@ class Person extends \Faker\Provider\Person
'Mulder', 'Enslin', 'Truter', 'Khuzwayo', 'Makhanya', 'Harmse', 'Loubser', 'Kleynhans', 'Paul', 'Nieuwoudt', 'Horn',
'Vosloo', 'Wentzel', 'Munyai', 'Kelly', 'Walters', 'Nzimande', 'Hoosen', 'Mkhabela', 'Madlala', 'Saunders', 'Palmer',
'Hughes', 'Hanekom', 'Ally', 'Schmidt', 'Butler', 'Mtsweni', 'Maphumulo', 'Manamela', 'Hoffman', 'Wolmarans', 'Duma',
'Pule', 'Hlophe', 'Miya', 'Moagi'
'Pule', 'Hlophe', 'Miya', 'Moagi',
);
}
2 changes: 1 addition & 1 deletion src/Faker/Provider/en_ZA/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class PhoneNumber extends \Faker\Provider\PhoneNumber
'0##-###-####',
'(0##)###-####',
'0-800-###-####',
'### ####'
'### ####',
);
}
26 changes: 26 additions & 0 deletions test/Faker/Provider/en_ZA/CompanyTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Faker\Test\Provider\en_ZA;

use Faker\Generator;
use Faker\Provider\en_ZA\Company;

class CompanyTest extends \PHPUnit_Framework_TestCase
{
private $faker;

public function setUp()
{
$faker = new Generator();
$faker->addProvider(new Company($faker));
$this->faker = $faker;
}

public function testGenerateValidCompanyNumber()
{
$companyRegNo = $this->faker->companyNumber();

$this->assertEquals(14, strlen($companyRegNo));
$this->assertRegExp('#^\d{4}/\d{6}/\d{2}$#', $companyRegNo);
}
}

0 comments on commit e0d369d

Please sign in to comment.