1
0
mirror of https://github.com/fzaninotto/Faker.git synced 2025-03-22 00:09:59 +01:00

Merge branch 'master' of github.com:fzaninotto/Faker

This commit is contained in:
Francois Zaninotto 2011-10-21 21:43:39 +02:00
commit 3f4f69afba
7 changed files with 35 additions and 9 deletions

View File

@ -55,7 +55,7 @@ for ($i=0; $i < 10; $i++) {
Each of the generator properties (like `name`, `address`, and `lorem`) are called "formatters". A faker generator has many of them, packaged in "providers". Here is a list of the bundled formatters in the default locale.
### `Faker\Provider\en_US\Name`
### `Faker\Provider\en_US\Person`
prefix // 'Ms.'
suffix // 'Jr.'

View File

@ -8,7 +8,7 @@ class Factory
{
const DEFAULT_LOCALE = 'en_US';
protected static $defaultProviders = array('Name', 'Address', 'PhoneNumber', 'Company', 'Lorem', 'Internet', 'DateTime', 'Miscellaneous');
protected static $defaultProviders = array('Person', 'Address', 'PhoneNumber', 'Company', 'Lorem', 'Internet', 'DateTime', 'Miscellaneous');
public static function create($locale = self::DEFAULT_LOCALE)
{

View File

@ -50,7 +50,7 @@ class Base
*/
protected static function numerify($string)
{
return preg_replace_callback('/\#/', get_called_class() . '::randomDigit', $string);
return preg_replace_callback('/\#/', 'static::randomDigit', $string);
}
/**
@ -61,7 +61,7 @@ class Base
*/
protected static function lexify($string)
{
return preg_replace_callback('/\?/', get_called_class() . '::randomLetter', $string);
return preg_replace_callback('/\?/', 'static::randomLetter', $string);
}
/**

View File

@ -9,6 +9,8 @@ class DateTime extends \Faker\Provider\Base
protected static $century = array('I','II','III','IV','V','VI','VII','VIII','IX','X','XI','XII','XIII','XIV','XV','XVI','XVII','XVIII','XIX','XX','XX1');
/**
* Get a timestamp between January 1, 1970 and now
*
* @example 1061306726
*/
public static function unixTime()
@ -17,6 +19,8 @@ class DateTime extends \Faker\Provider\Base
}
/**
* Get a datetime object for a date between January 1, 1970 and now
*
* @example DateTime('2005-08-16 20:39:21')
* @return \DateTime
*/
@ -24,6 +28,17 @@ class DateTime extends \Faker\Provider\Base
{
return new \DateTime('@' . static::unixTime());
}
/**
* Get a datetime object for a date between January 1, 001 and now
*
* @example DateTime('1265-03-22 21:15:52')
* @return \DateTime
*/
public static function dateTimeAD()
{
return new \DateTime('@' . mt_rand(-62135597361, time()));
}
/**
* @example '2003-10-21T16:05:52+0000'
@ -34,6 +49,9 @@ class DateTime extends \Faker\Provider\Base
}
/**
* Get a date string between January 1, 1970 and now
*
* @param string $format
* @example '2008-11-27'
*/
public static function date($format = 'Y-m-d')
@ -42,6 +60,9 @@ class DateTime extends \Faker\Provider\Base
}
/**
* Get a time string (24h format by default)
*
* @param string $format
* @example '15:02:34'
*/
public static function time($format = 'H:i:s')
@ -50,6 +71,11 @@ class DateTime extends \Faker\Provider\Base
}
/**
* Get a DateTime object based on a random date between two given dates.
* Accepts date strings that can be recognized by strtotime().
*
* @param string $startDate Defaults to 30 years ago
* @param string $endDate Defaults to "now"
* @example DateTime('1999-02-02 11:42:52')
* @return \DateTime
*/

View File

@ -4,7 +4,7 @@ namespace Faker\Provider;
require_once __DIR__ . '/Base.php';
class Name extends \Faker\Provider\Base
class Person extends \Faker\Provider\Base
{
protected static $formats = array(
'{{firstName}} {{lastName}}',

View File

@ -2,9 +2,9 @@
namespace Faker\Provider\en_US;
require_once __DIR__ . '/../Name.php';
require_once __DIR__ . '/../Person.php';
class Name extends \Faker\Provider\Name
class Person extends \Faker\Provider\Person
{
protected static $formats = array(
'{{firstName}} {{lastName}}',

View File

@ -2,9 +2,9 @@
namespace Faker\Provider\fr_FR;
require_once __DIR__ . '/../Name.php';
require_once __DIR__ . '/../Person.php';
class Name extends \Faker\Provider\Name
class Person extends \Faker\Provider\Person
{
protected static $formats = array(
'{{firstName}} {{lastName}}',