vendor and env first commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
/**
|
||||
* @experimental This interface is experimental and does not fall under our BC promise
|
||||
*/
|
||||
interface AddressExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* @example '791 Crist Parks, Sashabury, IL 86039-9874'
|
||||
*/
|
||||
public function address(): string;
|
||||
|
||||
/**
|
||||
* Randomly return a real city name.
|
||||
*/
|
||||
public function city(): string;
|
||||
|
||||
/**
|
||||
* @example 86039-9874
|
||||
*/
|
||||
public function postcode(): string;
|
||||
|
||||
/**
|
||||
* @example 'Crist Parks'
|
||||
*/
|
||||
public function streetName(): string;
|
||||
|
||||
/**
|
||||
* @example '791 Crist Parks'
|
||||
*/
|
||||
public function streetAddress(): string;
|
||||
|
||||
/**
|
||||
* Randomly return a building number.
|
||||
*/
|
||||
public function buildingNumber(): string;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
/**
|
||||
* @experimental This interface is experimental and does not fall under our BC promise
|
||||
*/
|
||||
interface BarcodeExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* Get a random EAN13 barcode.
|
||||
*
|
||||
* @example '4006381333931'
|
||||
*/
|
||||
public function ean13(): string;
|
||||
|
||||
/**
|
||||
* Get a random EAN8 barcode.
|
||||
*
|
||||
* @example '73513537'
|
||||
*/
|
||||
public function ean8(): string;
|
||||
|
||||
/**
|
||||
* Get a random ISBN-10 code
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/International_Standard_Book_Number
|
||||
*
|
||||
* @example '4881416324'
|
||||
*/
|
||||
public function isbn10(): string;
|
||||
|
||||
/**
|
||||
* Get a random ISBN-13 code
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/International_Standard_Book_Number
|
||||
*
|
||||
* @example '9790404436093'
|
||||
*/
|
||||
public function isbn13(): string;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
/**
|
||||
* @experimental This interface is experimental and does not fall under our BC promise
|
||||
*/
|
||||
interface BloodExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* Get an actual blood type
|
||||
*
|
||||
* @example 'AB'
|
||||
*/
|
||||
public function bloodType(): string;
|
||||
|
||||
/**
|
||||
* Get a random resis value
|
||||
*
|
||||
* @example '+'
|
||||
*/
|
||||
public function bloodRh(): string;
|
||||
|
||||
/**
|
||||
* Get a full blood group
|
||||
*
|
||||
* @example 'AB+'
|
||||
*/
|
||||
public function bloodGroup(): string;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
/**
|
||||
* @experimental This interface is experimental and does not fall under our BC promise
|
||||
*/
|
||||
interface ColorExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* @example '#fa3cc2'
|
||||
*/
|
||||
public function hexColor(): string;
|
||||
|
||||
/**
|
||||
* @example '#ff0044'
|
||||
*/
|
||||
public function safeHexColor(): string;
|
||||
|
||||
/**
|
||||
* @example 'array(0,255,122)'
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function rgbColorAsArray(): array;
|
||||
|
||||
/**
|
||||
* @example '0,255,122'
|
||||
*/
|
||||
public function rgbColor(): string;
|
||||
|
||||
/**
|
||||
* @example 'rgb(0,255,122)'
|
||||
*/
|
||||
public function rgbCssColor(): string;
|
||||
|
||||
/**
|
||||
* @example 'rgba(0,255,122,0.8)'
|
||||
*/
|
||||
public function rgbaCssColor(): string;
|
||||
|
||||
/**
|
||||
* @example 'blue'
|
||||
*/
|
||||
public function safeColorName(): string;
|
||||
|
||||
/**
|
||||
* @example 'NavajoWhite'
|
||||
*/
|
||||
public function colorName(): string;
|
||||
|
||||
/**
|
||||
* @example '340,50,20'
|
||||
*/
|
||||
public function hslColor(): string;
|
||||
|
||||
/**
|
||||
* @example array(340, 50, 20)
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function hslColorAsArray(): array;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
/**
|
||||
* @experimental This interface is experimental and does not fall under our BC promise
|
||||
*/
|
||||
interface CompanyExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* @example 'Acme Ltd'
|
||||
*/
|
||||
public function company(): string;
|
||||
|
||||
/**
|
||||
* @example 'Ltd'
|
||||
*/
|
||||
public function companySuffix(): string;
|
||||
|
||||
public function jobTitle(): string;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
/**
|
||||
* @experimental This interface is experimental and does not fall under our BC promise
|
||||
*/
|
||||
interface CountryExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* @example 'Japan'
|
||||
*/
|
||||
public function country(): string;
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
/**
|
||||
* FakerPHP extension for Date-related randomization.
|
||||
*
|
||||
* Functions accepting a date string use the `strtotime()` function internally.
|
||||
*
|
||||
* @experimental
|
||||
*
|
||||
* @since 1.20.0
|
||||
*/
|
||||
interface DateTimeExtension
|
||||
{
|
||||
/**
|
||||
* Get a DateTime object between January 1, 1970, and `$until` (defaults to "now").
|
||||
*
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
* @param string|null $timezone zone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
|
||||
*
|
||||
* @see \DateTimeZone
|
||||
* @see http://php.net/manual/en/timezones.php
|
||||
* @see http://php.net/manual/en/function.date-default-timezone-get.php
|
||||
*
|
||||
* @example DateTime('2005-08-16 20:39:21')
|
||||
*/
|
||||
public function dateTime($until = 'now', string $timezone = null): \DateTime;
|
||||
|
||||
/**
|
||||
* Get a DateTime object for a date between January 1, 0001, and now.
|
||||
*
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
* @param string|null $timezone zone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
|
||||
*
|
||||
* @example DateTime('1265-03-22 21:15:52')
|
||||
*
|
||||
* @see http://php.net/manual/en/timezones.php
|
||||
* @see http://php.net/manual/en/function.date-default-timezone-get.php
|
||||
*/
|
||||
public function dateTimeAD($until = 'now', string $timezone = null): \DateTime;
|
||||
|
||||
/**
|
||||
* Get a DateTime object a random date between `$from` and `$until`.
|
||||
* Accepts date strings that can be recognized by `strtotime()`.
|
||||
*
|
||||
* @param \DateTime|string $from defaults to 30 years ago
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
* @param string|null $timezone zone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
|
||||
*
|
||||
* @see \DateTimeZone
|
||||
* @see http://php.net/manual/en/timezones.php
|
||||
* @see http://php.net/manual/en/function.date-default-timezone-get.php
|
||||
*/
|
||||
public function dateTimeBetween($from = '-30 years', $until = 'now', string $timezone = null): \DateTime;
|
||||
|
||||
/**
|
||||
* Get a DateTime object based on a random date between `$from` and an interval.
|
||||
* Accepts date string that can be recognized by `strtotime()`.
|
||||
*
|
||||
* @param \DateTime|int|string $from defaults to 30 years ago
|
||||
* @param string $interval defaults to 5 days after
|
||||
* @param string|null $timezone zone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
|
||||
*
|
||||
* @see \DateTimeZone
|
||||
* @see http://php.net/manual/en/timezones.php
|
||||
* @see http://php.net/manual/en/function.date-default-timezone-get.php
|
||||
*/
|
||||
public function dateTimeInInterval($from = '-30 years', string $interval = '+5 days', string $timezone = null): \DateTime;
|
||||
|
||||
/**
|
||||
* Get a date time object somewhere inside the current week.
|
||||
*
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
* @param string|null $timezone zone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
|
||||
*
|
||||
* @see \DateTimeZone
|
||||
* @see http://php.net/manual/en/timezones.php
|
||||
* @see http://php.net/manual/en/function.date-default-timezone-get.php
|
||||
*/
|
||||
public function dateTimeThisWeek($until = 'now', string $timezone = null): \DateTime;
|
||||
|
||||
/**
|
||||
* Get a date time object somewhere inside the current month.
|
||||
*
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
* @param string|null $timezone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
|
||||
*
|
||||
* @see \DateTimeZone
|
||||
* @see http://php.net/manual/en/timezones.php
|
||||
* @see http://php.net/manual/en/function.date-default-timezone-get.php
|
||||
*/
|
||||
public function dateTimeThisMonth($until = 'now', string $timezone = null): \DateTime;
|
||||
|
||||
/**
|
||||
* Get a date time object somewhere inside the current year.
|
||||
*
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
* @param string|null $timezone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
|
||||
*
|
||||
* @see \DateTimeZone
|
||||
* @see http://php.net/manual/en/timezones.php
|
||||
* @see http://php.net/manual/en/function.date-default-timezone-get.php
|
||||
*/
|
||||
public function dateTimeThisYear($until = 'now', string $timezone = null): \DateTime;
|
||||
|
||||
/**
|
||||
* Get a date time object somewhere inside the current decade.
|
||||
*
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
* @param string|null $timezone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
|
||||
*
|
||||
* @see \DateTimeZone
|
||||
* @see http://php.net/manual/en/timezones.php
|
||||
* @see http://php.net/manual/en/function.date-default-timezone-get.php
|
||||
*/
|
||||
public function dateTimeThisDecade($until = 'now', string $timezone = null): \DateTime;
|
||||
|
||||
/**
|
||||
* Get a date time object somewhere inside the current century.
|
||||
*
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
* @param string|null $timezone timezone for generated date, fallback to `DateTime::$defaultTimezone` and `date_default_timezone_get()`.
|
||||
*
|
||||
* @see \DateTimeZone
|
||||
* @see http://php.net/manual/en/timezones.php
|
||||
* @see http://php.net/manual/en/function.date-default-timezone-get.php
|
||||
*/
|
||||
public function dateTimeThisCentury($until = 'now', string $timezone = null): \DateTime;
|
||||
|
||||
/**
|
||||
* Get a date string between January 1, 1970, and `$until`.
|
||||
*
|
||||
* @param string $format DateTime format
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
*
|
||||
* @see https://www.php.net/manual/en/datetime.format.php
|
||||
*/
|
||||
public function date(string $format = 'Y-m-d', $until = 'now'): string;
|
||||
|
||||
/**
|
||||
* Get a time string (24h format by default).
|
||||
*
|
||||
* @param string $format DateTime format
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
*
|
||||
* @see https://www.php.net/manual/en/datetime.format.php
|
||||
*/
|
||||
public function time(string $format = 'H:i:s', $until = 'now'): string;
|
||||
|
||||
/**
|
||||
* Get a UNIX (POSIX-compatible) timestamp between January 1, 1970, and `$until`.
|
||||
*
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
*/
|
||||
public function unixTime($until = 'now'): int;
|
||||
|
||||
/**
|
||||
* Get a date string according to the ISO-8601 standard.
|
||||
*
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
*/
|
||||
public function iso8601($until = 'now'): string;
|
||||
|
||||
/**
|
||||
* Get a string containing either "am" or "pm".
|
||||
*
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
*
|
||||
* @example 'am'
|
||||
*/
|
||||
public function amPm($until = 'now'): string;
|
||||
|
||||
/**
|
||||
* Get a localized random day of the month.
|
||||
*
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
*
|
||||
* @example '16'
|
||||
*/
|
||||
public function dayOfMonth($until = 'now'): string;
|
||||
|
||||
/**
|
||||
* Get a localized random day of the week.
|
||||
*
|
||||
* Uses internal DateTime formatting, hence PHP's internal locale will be used (change using `setlocale()`).
|
||||
*
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
*
|
||||
* @example 'Tuesday'
|
||||
*
|
||||
* @see setlocale
|
||||
* @see https://www.php.net/manual/en/function.setlocale.php Set a different output language
|
||||
*/
|
||||
public function dayOfWeek($until = 'now'): string;
|
||||
|
||||
/**
|
||||
* Get a random month (numbered).
|
||||
*
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
*
|
||||
* @example '7'
|
||||
*/
|
||||
public function month($until = 'now'): string;
|
||||
|
||||
/**
|
||||
* Get a random month.
|
||||
*
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
*
|
||||
* @see setlocale
|
||||
* @see https://www.php.net/manual/en/function.setlocale.php Set a different output language
|
||||
*
|
||||
* @example 'September'
|
||||
*/
|
||||
public function monthName($until = 'now'): string;
|
||||
|
||||
/**
|
||||
* Get a random year between 1970 and `$until`.
|
||||
*
|
||||
* @param \DateTime|int|string $until maximum timestamp, defaults to "now"
|
||||
*
|
||||
* @example '1987'
|
||||
*/
|
||||
public function year($until = 'now'): string;
|
||||
|
||||
/**
|
||||
* Get a random century, formatted as Roman numerals.
|
||||
*
|
||||
* @example 'XVII'
|
||||
*/
|
||||
public function century(): string;
|
||||
|
||||
/**
|
||||
* Get a random timezone, uses `\DateTimeZone::listIdentifiers()` internally.
|
||||
*
|
||||
* @param string|null $countryCode two-letter ISO 3166-1 compatible country code
|
||||
*
|
||||
* @example 'Europe/Rome'
|
||||
*/
|
||||
public function timezone(string $countryCode = null): string;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
/**
|
||||
* An extension is the only way to add new functionality to Faker.
|
||||
*
|
||||
* @experimental This interface is experimental and does not fall under our BC promise
|
||||
*/
|
||||
interface Extension
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
/**
|
||||
* @experimental This class is experimental and does not fall under our BC promise
|
||||
*/
|
||||
final class ExtensionNotFound extends \LogicException
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
/**
|
||||
* @experimental This interface is experimental and does not fall under our BC promise
|
||||
*/
|
||||
interface FileExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* Get a random MIME type
|
||||
*
|
||||
* @example 'video/avi'
|
||||
*/
|
||||
public function mimeType(): string;
|
||||
|
||||
/**
|
||||
* Get a random file extension (without a dot)
|
||||
*
|
||||
* @example avi
|
||||
*/
|
||||
public function extension(): string;
|
||||
|
||||
/**
|
||||
* Get a full path to a new real file on the system.
|
||||
*/
|
||||
public function filePath(): string;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
use Faker\Generator;
|
||||
|
||||
/**
|
||||
* @experimental This interface is experimental and does not fall under our BC promise
|
||||
*/
|
||||
interface GeneratorAwareExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* This method MUST be implemented in such a way as to retain the
|
||||
* immutability of the extension, and MUST return an instance that has the
|
||||
* new Generator.
|
||||
*/
|
||||
public function withGenerator(Generator $generator): Extension;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
use Faker\Generator;
|
||||
|
||||
/**
|
||||
* A helper trait to be used with GeneratorAwareExtension.
|
||||
*/
|
||||
trait GeneratorAwareExtensionTrait
|
||||
{
|
||||
/**
|
||||
* @var Generator|null
|
||||
*/
|
||||
private $generator;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function withGenerator(Generator $generator): Extension
|
||||
{
|
||||
$instance = clone $this;
|
||||
|
||||
$instance->generator = $generator;
|
||||
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
/**
|
||||
* A class with some methods that may make building extensions easier.
|
||||
*
|
||||
* @experimental This class is experimental and does not fall under our BC promise
|
||||
*/
|
||||
final class Helper
|
||||
{
|
||||
/**
|
||||
* Returns a random element from a passed array.
|
||||
*/
|
||||
public static function randomElement(array $array)
|
||||
{
|
||||
if ($array === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $array[array_rand($array, 1)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all hash sign ('#') occurrences with a random number
|
||||
* Replaces all percentage sign ('%') occurrences with a non-zero number.
|
||||
*
|
||||
* @param string $string String that needs to bet parsed
|
||||
*/
|
||||
public static function numerify(string $string): string
|
||||
{
|
||||
// instead of using randomDigit() several times, which is slow,
|
||||
// count the number of hashes and generate once a large number
|
||||
$toReplace = [];
|
||||
|
||||
if (($pos = strpos($string, '#')) !== false) {
|
||||
for ($i = $pos, $last = strrpos($string, '#', $pos) + 1; $i < $last; ++$i) {
|
||||
if ($string[$i] === '#') {
|
||||
$toReplace[] = $i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($nbReplacements = count($toReplace)) {
|
||||
$maxAtOnce = strlen((string) mt_getrandmax()) - 1;
|
||||
$numbers = '';
|
||||
$i = 0;
|
||||
|
||||
while ($i < $nbReplacements) {
|
||||
$size = min($nbReplacements - $i, $maxAtOnce);
|
||||
$numbers .= str_pad((string) mt_rand(0, 10 ** $size - 1), $size, '0', STR_PAD_LEFT);
|
||||
$i += $size;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $nbReplacements; ++$i) {
|
||||
$string[$toReplace[$i]] = $numbers[$i];
|
||||
}
|
||||
}
|
||||
|
||||
return self::replaceWildcard($string, '%', static function () {
|
||||
return mt_rand(1, 9);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all question mark ('?') occurrences with a random letter.
|
||||
*
|
||||
* @param string $string String that needs to bet parsed
|
||||
*/
|
||||
public static function lexify(string $string): string
|
||||
{
|
||||
return self::replaceWildcard($string, '?', static function () {
|
||||
return chr(mt_rand(97, 122));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces hash signs ('#') and question marks ('?') with random numbers and letters
|
||||
* An asterisk ('*') is replaced with either a random number or a random letter.
|
||||
*
|
||||
* @param string $string String that needs to bet parsed
|
||||
*/
|
||||
public static function bothify(string $string): string
|
||||
{
|
||||
$string = self::replaceWildcard($string, '*', static function () {
|
||||
return mt_rand(0, 1) === 1 ? '#' : '?';
|
||||
});
|
||||
|
||||
return self::lexify(self::numerify($string));
|
||||
}
|
||||
|
||||
private static function replaceWildcard(string $string, string $wildcard, callable $callback): string
|
||||
{
|
||||
if (($pos = strpos($string, $wildcard)) === false) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
for ($i = $pos, $last = strrpos($string, $wildcard, $pos) + 1; $i < $last; ++$i) {
|
||||
if ($string[$i] === $wildcard) {
|
||||
$string[$i] = call_user_func($callback);
|
||||
}
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
/**
|
||||
* @experimental This interface is experimental and does not fall under our BC promise
|
||||
*/
|
||||
interface NumberExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* Returns a random number between $int1 and $int2 (any order)
|
||||
*
|
||||
* @param int $min default to 0
|
||||
* @param int $max defaults to 32 bit max integer, ie 2147483647
|
||||
*
|
||||
* @example 79907610
|
||||
*/
|
||||
public function numberBetween(int $min, int $max): int;
|
||||
|
||||
/**
|
||||
* Returns a random number between 0 and 9
|
||||
*/
|
||||
public function randomDigit(): int;
|
||||
|
||||
/**
|
||||
* Generates a random digit, which cannot be $except
|
||||
*/
|
||||
public function randomDigitNot(int $except): int;
|
||||
|
||||
/**
|
||||
* Returns a random number between 1 and 9
|
||||
*/
|
||||
public function randomDigitNotZero(): int;
|
||||
|
||||
/**
|
||||
* Return a random float number
|
||||
*
|
||||
* @example 48.8932
|
||||
*/
|
||||
public function randomFloat(?int $nbMaxDecimals, float $min, ?float $max): float;
|
||||
|
||||
/**
|
||||
* Returns a random integer with 0 to $nbDigits digits.
|
||||
*
|
||||
* The maximum value returned is mt_getrandmax()
|
||||
*
|
||||
* @param int|null $nbDigits Defaults to a random number between 1 and 9
|
||||
* @param bool $strict Whether the returned number should have exactly $nbDigits
|
||||
*
|
||||
* @example 79907610
|
||||
*/
|
||||
public function randomNumber(?int $nbDigits, bool $strict): int;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
/**
|
||||
* @experimental This interface is experimental and does not fall under our BC promise
|
||||
*/
|
||||
interface PersonExtension extends Extension
|
||||
{
|
||||
public const GENDER_FEMALE = 'female';
|
||||
public const GENDER_MALE = 'male';
|
||||
|
||||
/**
|
||||
* @param string|null $gender 'male', 'female' or null for any
|
||||
*
|
||||
* @example 'John Doe'
|
||||
*/
|
||||
public function name(?string $gender = null): string;
|
||||
|
||||
/**
|
||||
* @param string|null $gender 'male', 'female' or null for any
|
||||
*
|
||||
* @example 'John'
|
||||
*/
|
||||
public function firstName(?string $gender = null): string;
|
||||
|
||||
public function firstNameMale(): string;
|
||||
|
||||
public function firstNameFemale(): string;
|
||||
|
||||
/**
|
||||
* @example 'Doe'
|
||||
*/
|
||||
public function lastName(): string;
|
||||
|
||||
/**
|
||||
* @example 'Mrs.'
|
||||
*
|
||||
* @param string|null $gender 'male', 'female' or null for any
|
||||
*/
|
||||
public function title(?string $gender = null): string;
|
||||
|
||||
/**
|
||||
* @example 'Mr.'
|
||||
*/
|
||||
public function titleMale(): string;
|
||||
|
||||
/**
|
||||
* @example 'Mrs.'
|
||||
*/
|
||||
public function titleFemale(): string;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
/**
|
||||
* @experimental This interface is experimental and does not fall under our BC promise
|
||||
*/
|
||||
interface PhoneNumberExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* @example '555-123-546'
|
||||
*/
|
||||
public function phoneNumber(): string;
|
||||
|
||||
/**
|
||||
* @example +27113456789
|
||||
*/
|
||||
public function e164PhoneNumber(): string;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
/**
|
||||
* @experimental This interface is experimental and does not fall under our BC promise
|
||||
*/
|
||||
interface UuidExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* Generate name based md5 UUID (version 3).
|
||||
*
|
||||
* @example '7e57d004-2b97-0e7a-b45f-5387367791cd'
|
||||
*/
|
||||
public function uuid3(): string;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Extension;
|
||||
|
||||
/**
|
||||
* @experimental This interface is experimental and does not fall under our BC promise
|
||||
*/
|
||||
interface VersionExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* Get a version number in semantic versioning syntax 2.0.0. (https://semver.org/spec/v2.0.0.html)
|
||||
*
|
||||
* @param bool $preRelease Pre release parts may be randomly included
|
||||
* @param bool $build Build parts may be randomly included
|
||||
*
|
||||
* @example 1.0.0
|
||||
* @example 1.0.0-alpha.1
|
||||
* @example 1.0.0-alpha.1+b71f04d
|
||||
*/
|
||||
public function semver(bool $preRelease = false, bool $build = false): string;
|
||||
}
|
||||
Reference in New Issue
Block a user