1
0
mirror of https://github.com/fzaninotto/Faker.git synced 2025-03-19 06:49:50 +01:00

Updated: Danish provider & Readme

This commit is contained in:
toin0u 2012-11-10 20:22:01 +01:00 committed by Antoine Corcy
parent 4508f34a79
commit f7c80bec98
4 changed files with 78 additions and 7 deletions

View File

@ -565,6 +565,43 @@ echo $faker->region; // "Saint-Pierre-et-Miquelon"
```
### `Faker\Provider\da_DK\Person`
```php
<?php
// Generates a random CPR number
echo $faker->cpr; // "051280-2387"
```
### `Faker\Provider\da_DK\Address`
```php
<?php
// Generates a random 'kommune' name
echo $faker->kommune; // "Frederiksberg"
// Generates a random region name
echo $faker->region; // "Region Sjælland"
```
### `Faker\Provider\da_DK\Company`
```php
<?php
// Generates a random CVR number
echo $faker->cvr; // "32458723"
// Generates a random P number
echo $faker->p; // "5398237590"
```
## License
Faker is released under the MIT Licence. See the bundled LICENSE file for details.

View File

@ -119,9 +119,9 @@ class Address extends \Faker\Provider\Address
);
/**
* @var array Danish municipalities.
* @var array Danish municipalities, called 'kommuner' in danish.
*/
protected static $municipalityNames = array(
protected static $kommuneNames = array(
'København','Frederiksberg','Ballerup','Brøndby','Dragør','Gentofte','Gladsaxe','Glostrup','Herlev',
'Albertslund','Hvidovre','Høje Taastrup','Lyngby-Taarbæk','Rødovre','Ishøj','Tårnby','Vallensbæk',
'Allerød','Fredensborg','Helsingør','Hillerød','Hørsholm','Rudersdal','Egedal','Frederikssund','Greve',
@ -265,9 +265,9 @@ class Address extends \Faker\Provider\Address
*
* @return string
*/
public static function municipality()
public static function kommune()
{
return static::randomElement(static::$municipalityNames);
return static::randomElement(static::$kommuneNames);
}
/**

View File

@ -35,12 +35,21 @@ class Company extends \Faker\Provider\Company
protected static $companySuffix = array('ApS', 'A/S', 'I/S', 'K/S');
/**
* @var string CVR format.
* @link http://cvr.dk/Site/Forms/CMS/DisplayPage.aspx?pageid=60
*
* @var string CVR number format.
*/
protected static $cvrFormat = "%#######";
protected static $cvrFormat = '%#######';
/**
* Generates a cvr number (8 digits).
* @link http://cvr.dk/Site/Forms/CMS/DisplayPage.aspx?pageid=60
*
* @var string P number (production number) format.
*/
protected static $pFormat = '%#########';
/**
* Generates a CVR number (8 digits).
*
* @return string
*/
@ -48,4 +57,14 @@ class Company extends \Faker\Provider\Company
{
return static::numerify(static::$cvrFormat);
}
/**
* Generates a P entity number (10 digits).
*
* @return string
*/
public static function p()
{
return static::numerify(static::$pFormat);
}
}

View File

@ -165,4 +165,19 @@ class Person extends \Faker\Provider\Person
{
return static::randomElement(static::$middleName);
}
/**
* Randomly return a danish CPR number (Personnal identification number) format.
*
* @link http://cpr.dk/cpr/site.aspx?p=16
* @link http://en.wikipedia.org/wiki/Personal_identification_number_%28Denmark%29
*
* @return string
*/
public static function cpr()
{
$birthdate = new \DateTime('@' . mt_rand(0, time()));
return sprintf('%s-%s', $birthdate->format('dmy'), static::numerify('%###'));
}
}