vendor/fakerphp/faker/src/Faker/Generator.php line 942

Open in your IDE?
  1. <?php
  2. namespace Faker;
  3. use Psr\Container\ContainerInterface;
  4. /**
  5.  * @property string $citySuffix
  6.  *
  7.  * @method string citySuffix()
  8.  *
  9.  * @property string $streetSuffix
  10.  *
  11.  * @method string streetSuffix()
  12.  *
  13.  * @property string $buildingNumber
  14.  *
  15.  * @method string buildingNumber()
  16.  *
  17.  * @property string $city
  18.  *
  19.  * @method string city()
  20.  *
  21.  * @property string $streetName
  22.  *
  23.  * @method string streetName()
  24.  *
  25.  * @property string $streetAddress
  26.  *
  27.  * @method string streetAddress()
  28.  *
  29.  * @property string $postcode
  30.  *
  31.  * @method string postcode()
  32.  *
  33.  * @property string $address
  34.  *
  35.  * @method string address()
  36.  *
  37.  * @property string $country
  38.  *
  39.  * @method string country()
  40.  *
  41.  * @property float $latitude
  42.  *
  43.  * @method float latitude($min = -90, $max = 90)
  44.  *
  45.  * @property float $longitude
  46.  *
  47.  * @method float longitude($min = -180, $max = 180)
  48.  *
  49.  * @property float[] $localCoordinates
  50.  *
  51.  * @method float[] localCoordinates()
  52.  *
  53.  * @property int $randomDigitNotNull
  54.  *
  55.  * @method int randomDigitNotNull()
  56.  *
  57.  * @property mixed $passthrough
  58.  *
  59.  * @method mixed passthrough($value)
  60.  *
  61.  * @property string $randomLetter
  62.  *
  63.  * @method string randomLetter()
  64.  *
  65.  * @property string $randomAscii
  66.  *
  67.  * @method string randomAscii()
  68.  *
  69.  * @property array $randomElements
  70.  *
  71.  * @method array randomElements($array = ['a', 'b', 'c'], $count = 1, $allowDuplicates = false)
  72.  *
  73.  * @property mixed $randomElement
  74.  *
  75.  * @method mixed randomElement($array = ['a', 'b', 'c'])
  76.  *
  77.  * @property int|string|null $randomKey
  78.  *
  79.  * @method int|string|null randomKey($array = [])
  80.  *
  81.  * @property array|string $shuffle
  82.  *
  83.  * @method array|string shuffle($arg = '')
  84.  *
  85.  * @property array $shuffleArray
  86.  *
  87.  * @method array shuffleArray($array = [])
  88.  *
  89.  * @property string $shuffleString
  90.  *
  91.  * @method string shuffleString($string = '', $encoding = 'UTF-8')
  92.  *
  93.  * @property string $numerify
  94.  *
  95.  * @method string numerify($string = '###')
  96.  *
  97.  * @property string $lexify
  98.  *
  99.  * @method string lexify($string = '????')
  100.  *
  101.  * @property string $bothify
  102.  *
  103.  * @method string bothify($string = '## ??')
  104.  *
  105.  * @property string $asciify
  106.  *
  107.  * @method string asciify($string = '****')
  108.  *
  109.  * @property string $regexify
  110.  *
  111.  * @method string regexify($regex = '')
  112.  *
  113.  * @property string $toLower
  114.  *
  115.  * @method string toLower($string = '')
  116.  *
  117.  * @property string $toUpper
  118.  *
  119.  * @method string toUpper($string = '')
  120.  *
  121.  * @property int $biasedNumberBetween
  122.  *
  123.  * @method int biasedNumberBetween($min = 0, $max = 100, $function = 'sqrt')
  124.  *
  125.  * @property string $hexColor
  126.  *
  127.  * @method string hexColor()
  128.  *
  129.  * @property string $safeHexColor
  130.  *
  131.  * @method string safeHexColor()
  132.  *
  133.  * @property array $rgbColorAsArray
  134.  *
  135.  * @method array rgbColorAsArray()
  136.  *
  137.  * @property string $rgbColor
  138.  *
  139.  * @method string rgbColor()
  140.  *
  141.  * @property string $rgbCssColor
  142.  *
  143.  * @method string rgbCssColor()
  144.  *
  145.  * @property string $rgbaCssColor
  146.  *
  147.  * @method string rgbaCssColor()
  148.  *
  149.  * @property string $safeColorName
  150.  *
  151.  * @method string safeColorName()
  152.  *
  153.  * @property string $colorName
  154.  *
  155.  * @method string colorName()
  156.  *
  157.  * @property string $hslColor
  158.  *
  159.  * @method string hslColor()
  160.  *
  161.  * @property array $hslColorAsArray
  162.  *
  163.  * @method array hslColorAsArray()
  164.  *
  165.  * @property string $company
  166.  *
  167.  * @method string company()
  168.  *
  169.  * @property string $companySuffix
  170.  *
  171.  * @method string companySuffix()
  172.  *
  173.  * @property string $jobTitle
  174.  *
  175.  * @method string jobTitle()
  176.  *
  177.  * @property int $unixTime
  178.  *
  179.  * @method int unixTime($max = 'now')
  180.  *
  181.  * @property \DateTime $dateTime
  182.  *
  183.  * @method \DateTime dateTime($max = 'now', $timezone = null)
  184.  *
  185.  * @property \DateTime $dateTimeAD
  186.  *
  187.  * @method \DateTime dateTimeAD($max = 'now', $timezone = null)
  188.  *
  189.  * @property string $iso8601
  190.  *
  191.  * @method string iso8601($max = 'now')
  192.  *
  193.  * @property string $date
  194.  *
  195.  * @method string date($format = 'Y-m-d', $max = 'now')
  196.  *
  197.  * @property string $time
  198.  *
  199.  * @method string time($format = 'H:i:s', $max = 'now')
  200.  *
  201.  * @property \DateTime $dateTimeBetween
  202.  *
  203.  * @method \DateTime dateTimeBetween($startDate = '-30 years', $endDate = 'now', $timezone = null)
  204.  *
  205.  * @property \DateTime $dateTimeInInterval
  206.  *
  207.  * @method \DateTime dateTimeInInterval($date = '-30 years', $interval = '+5 days', $timezone = null)
  208.  *
  209.  * @property \DateTime $dateTimeThisCentury
  210.  *
  211.  * @method \DateTime dateTimeThisCentury($max = 'now', $timezone = null)
  212.  *
  213.  * @property \DateTime $dateTimeThisDecade
  214.  *
  215.  * @method \DateTime dateTimeThisDecade($max = 'now', $timezone = null)
  216.  *
  217.  * @property \DateTime $dateTimeThisYear
  218.  *
  219.  * @method \DateTime dateTimeThisYear($max = 'now', $timezone = null)
  220.  *
  221.  * @property \DateTime $dateTimeThisMonth
  222.  *
  223.  * @method \DateTime dateTimeThisMonth($max = 'now', $timezone = null)
  224.  *
  225.  * @property string $amPm
  226.  *
  227.  * @method string amPm($max = 'now')
  228.  *
  229.  * @property string $dayOfMonth
  230.  *
  231.  * @method string dayOfMonth($max = 'now')
  232.  *
  233.  * @property string $dayOfWeek
  234.  *
  235.  * @method string dayOfWeek($max = 'now')
  236.  *
  237.  * @property string $month
  238.  *
  239.  * @method string month($max = 'now')
  240.  *
  241.  * @property string $monthName
  242.  *
  243.  * @method string monthName($max = 'now')
  244.  *
  245.  * @property string $year
  246.  *
  247.  * @method string year($max = 'now')
  248.  *
  249.  * @property string $century
  250.  *
  251.  * @method string century()
  252.  *
  253.  * @property string $timezone
  254.  *
  255.  * @method string timezone()
  256.  *
  257.  * @property void $setDefaultTimezone
  258.  *
  259.  * @method void setDefaultTimezone($timezone = null)
  260.  *
  261.  * @property string $getDefaultTimezone
  262.  *
  263.  * @method string getDefaultTimezone()
  264.  *
  265.  * @property string $file
  266.  *
  267.  * @method string file($sourceDirectory = '/tmp', $targetDirectory = '/tmp', $fullPath = true)
  268.  *
  269.  * @property string $randomHtml
  270.  *
  271.  * @method string randomHtml($maxDepth = 4, $maxWidth = 4)
  272.  *
  273.  * @property string $imageUrl
  274.  *
  275.  * @method string imageUrl($width = 640, $height = 480, $category = null, $randomize = true, $word = null, $gray = false)
  276.  *
  277.  * @property string $image
  278.  *
  279.  * @method string image($dir = null, $width = 640, $height = 480, $category = null, $fullPath = true, $randomize = true, $word = null, $gray = false)
  280.  *
  281.  * @property string $email
  282.  *
  283.  * @method string email()
  284.  *
  285.  * @property string $safeEmail
  286.  *
  287.  * @method string safeEmail()
  288.  *
  289.  * @property string $freeEmail
  290.  *
  291.  * @method string freeEmail()
  292.  *
  293.  * @property string $companyEmail
  294.  *
  295.  * @method string companyEmail()
  296.  *
  297.  * @property string $freeEmailDomain
  298.  *
  299.  * @method string freeEmailDomain()
  300.  *
  301.  * @property string $safeEmailDomain
  302.  *
  303.  * @method string safeEmailDomain()
  304.  *
  305.  * @property string $userName
  306.  *
  307.  * @method string userName()
  308.  *
  309.  * @property string $password
  310.  *
  311.  * @method string password($minLength = 6, $maxLength = 20)
  312.  *
  313.  * @property string $domainName
  314.  *
  315.  * @method string domainName()
  316.  *
  317.  * @property string $domainWord
  318.  *
  319.  * @method string domainWord()
  320.  *
  321.  * @property string $tld
  322.  *
  323.  * @method string tld()
  324.  *
  325.  * @property string $url
  326.  *
  327.  * @method string url()
  328.  *
  329.  * @property string $slug
  330.  *
  331.  * @method string slug($nbWords = 6, $variableNbWords = true)
  332.  *
  333.  * @property string $ipv4
  334.  *
  335.  * @method string ipv4()
  336.  *
  337.  * @property string $ipv6
  338.  *
  339.  * @method string ipv6()
  340.  *
  341.  * @property string $localIpv4
  342.  *
  343.  * @method string localIpv4()
  344.  *
  345.  * @property string $macAddress
  346.  *
  347.  * @method string macAddress()
  348.  *
  349.  * @property string $word
  350.  *
  351.  * @method string word()
  352.  *
  353.  * @property array|string $words
  354.  *
  355.  * @method array|string words($nb = 3, $asText = false)
  356.  *
  357.  * @property string $sentence
  358.  *
  359.  * @method string sentence($nbWords = 6, $variableNbWords = true)
  360.  *
  361.  * @property array|string $sentences
  362.  *
  363.  * @method array|string sentences($nb = 3, $asText = false)
  364.  *
  365.  * @property string $paragraph
  366.  *
  367.  * @method string paragraph($nbSentences = 3, $variableNbSentences = true)
  368.  *
  369.  * @property array|string $paragraphs
  370.  *
  371.  * @method array|string paragraphs($nb = 3, $asText = false)
  372.  *
  373.  * @property string $text
  374.  *
  375.  * @method string text($maxNbChars = 200)
  376.  *
  377.  * @property bool $boolean
  378.  *
  379.  * @method bool boolean($chanceOfGettingTrue = 50)
  380.  *
  381.  * @property string $md5
  382.  *
  383.  * @method string md5()
  384.  *
  385.  * @property string $sha1
  386.  *
  387.  * @method string sha1()
  388.  *
  389.  * @property string $sha256
  390.  *
  391.  * @method string sha256()
  392.  *
  393.  * @property string $locale
  394.  *
  395.  * @method string locale()
  396.  *
  397.  * @property string $countryCode
  398.  *
  399.  * @method string countryCode()
  400.  *
  401.  * @property string $countryISOAlpha3
  402.  *
  403.  * @method string countryISOAlpha3()
  404.  *
  405.  * @property string $languageCode
  406.  *
  407.  * @method string languageCode()
  408.  *
  409.  * @property string $currencyCode
  410.  *
  411.  * @method string currencyCode()
  412.  *
  413.  * @property string $emoji
  414.  *
  415.  * @method string emoji()
  416.  *
  417.  * @property string $creditCardType
  418.  *
  419.  * @method string creditCardType()
  420.  *
  421.  * @property string $creditCardNumber
  422.  *
  423.  * @method string creditCardNumber($type = null, $formatted = false, $separator = '-')
  424.  *
  425.  * @property \DateTime $creditCardExpirationDate
  426.  *
  427.  * @method \DateTime creditCardExpirationDate($valid = true)
  428.  *
  429.  * @property string $creditCardExpirationDateString
  430.  *
  431.  * @method string creditCardExpirationDateString($valid = true, $expirationDateFormat = null)
  432.  *
  433.  * @property array $creditCardDetails
  434.  *
  435.  * @method array creditCardDetails($valid = true)
  436.  *
  437.  * @property string $iban
  438.  *
  439.  * @method string iban($countryCode = null, $prefix = '', $length = null)
  440.  *
  441.  * @property string $swiftBicNumber
  442.  *
  443.  * @method string swiftBicNumber()
  444.  *
  445.  * @property string $name
  446.  *
  447.  * @method string name($gender = null)
  448.  *
  449.  * @property string $firstName
  450.  *
  451.  * @method string firstName($gender = null)
  452.  *
  453.  * @property string $firstNameMale
  454.  *
  455.  * @method string firstNameMale()
  456.  *
  457.  * @property string $firstNameFemale
  458.  *
  459.  * @method string firstNameFemale()
  460.  *
  461.  * @property string $lastName
  462.  *
  463.  * @method string lastName()
  464.  *
  465.  * @property string $title
  466.  *
  467.  * @method string title($gender = null)
  468.  *
  469.  * @property string $titleMale
  470.  *
  471.  * @method string titleMale()
  472.  *
  473.  * @property string $titleFemale
  474.  *
  475.  * @method string titleFemale()
  476.  *
  477.  * @property string $phoneNumber
  478.  *
  479.  * @method string phoneNumber()
  480.  *
  481.  * @property string $e164PhoneNumber
  482.  *
  483.  * @method string e164PhoneNumber()
  484.  *
  485.  * @property int $imei
  486.  *
  487.  * @method int imei()
  488.  *
  489.  * @property string $realText
  490.  *
  491.  * @method string realText($maxNbChars = 200, $indexSize = 2)
  492.  *
  493.  * @property string $realTextBetween
  494.  *
  495.  * @method string realTextBetween($minNbChars = 160, $maxNbChars = 200, $indexSize = 2)
  496.  *
  497.  * @property string $macProcessor
  498.  *
  499.  * @method string macProcessor()
  500.  *
  501.  * @property string $linuxProcessor
  502.  *
  503.  * @method string linuxProcessor()
  504.  *
  505.  * @property string $userAgent
  506.  *
  507.  * @method string userAgent()
  508.  *
  509.  * @property string $chrome
  510.  *
  511.  * @method string chrome()
  512.  *
  513.  * @property string $firefox
  514.  *
  515.  * @method string firefox()
  516.  *
  517.  * @property string $safari
  518.  *
  519.  * @method string safari()
  520.  *
  521.  * @property string $opera
  522.  *
  523.  * @method string opera()
  524.  *
  525.  * @property string $internetExplorer
  526.  *
  527.  * @method string internetExplorer()
  528.  *
  529.  * @property string $windowsPlatformToken
  530.  *
  531.  * @method string windowsPlatformToken()
  532.  *
  533.  * @property string $macPlatformToken
  534.  *
  535.  * @method string macPlatformToken()
  536.  *
  537.  * @property string $linuxPlatformToken
  538.  *
  539.  * @method string linuxPlatformToken()
  540.  *
  541.  * @property string $uuid
  542.  *
  543.  * @method string uuid()
  544.  */
  545. class Generator
  546. {
  547.     protected $providers = [];
  548.     protected $formatters = [];
  549.     private $container;
  550.     /**
  551.      * @var UniqueGenerator
  552.      */
  553.     private $uniqueGenerator;
  554.     public function __construct(ContainerInterface $container null)
  555.     {
  556.         $this->container $container ?: Extension\ContainerBuilder::getDefault();
  557.     }
  558.     /**
  559.      * @template T of Extension\Extension
  560.      *
  561.      * @param class-string<T> $id
  562.      *
  563.      * @throws Extension\ExtensionNotFound
  564.      *
  565.      * @return T
  566.      */
  567.     public function ext(string $id): Extension\Extension
  568.     {
  569.         if (!$this->container->has($id)) {
  570.             throw new Extension\ExtensionNotFound(sprintf(
  571.                 'No Faker extension with id "%s" was loaded.',
  572.                 $id
  573.             ));
  574.         }
  575.         $extension $this->container->get($id);
  576.         if ($extension instanceof Extension\GeneratorAwareExtension) {
  577.             $extension $extension->withGenerator($this);
  578.         }
  579.         return $extension;
  580.     }
  581.     public function addProvider($provider)
  582.     {
  583.         array_unshift($this->providers$provider);
  584.         $this->formatters = [];
  585.     }
  586.     public function getProviders()
  587.     {
  588.         return $this->providers;
  589.     }
  590.     /**
  591.      * With the unique generator you are guaranteed to never get the same two
  592.      * values.
  593.      *
  594.      * <code>
  595.      * // will never return twice the same value
  596.      * $faker->unique()->randomElement(array(1, 2, 3));
  597.      * </code>
  598.      *
  599.      * @param bool $reset      If set to true, resets the list of existing values
  600.      * @param int  $maxRetries Maximum number of retries to find a unique value,
  601.      *                         After which an OverflowException is thrown.
  602.      *
  603.      * @throws \OverflowException When no unique value can be found by iterating $maxRetries times
  604.      *
  605.      * @return self A proxy class returning only non-existing values
  606.      */
  607.     public function unique($reset false$maxRetries 10000)
  608.     {
  609.         if ($reset || $this->uniqueGenerator === null) {
  610.             $this->uniqueGenerator = new UniqueGenerator($this$maxRetries);
  611.         }
  612.         return $this->uniqueGenerator;
  613.     }
  614.     /**
  615.      * Get a value only some percentage of the time.
  616.      *
  617.      * @param float $weight A probability between 0 and 1, 0 means that we always get the default value.
  618.      *
  619.      * @return self
  620.      */
  621.     public function optional(float $weight 0.5$default null)
  622.     {
  623.         if ($weight 1) {
  624.             trigger_deprecation('fakerphp/faker''1.16''First argument ($weight) to method "optional()" must be between 0 and 1. You passed %f, we assume you meant %f.'$weight$weight 100);
  625.             $weight $weight 100;
  626.         }
  627.         return new ChanceGenerator($this$weight$default);
  628.     }
  629.     /**
  630.      * To make sure the value meet some criteria, pass a callable that verifies the
  631.      * output. If the validator fails, the generator will try again.
  632.      *
  633.      * The value validity is determined by a function passed as first argument.
  634.      *
  635.      * <code>
  636.      * $values = array();
  637.      * $evenValidator = function ($digit) {
  638.      *   return $digit % 2 === 0;
  639.      * };
  640.      * for ($i=0; $i < 10; $i++) {
  641.      *   $values []= $faker->valid($evenValidator)->randomDigit;
  642.      * }
  643.      * print_r($values); // [0, 4, 8, 4, 2, 6, 0, 8, 8, 6]
  644.      * </code>
  645.      *
  646.      * @param ?\Closure $validator  A function returning true for valid values
  647.      * @param int       $maxRetries Maximum number of retries to find a valid value,
  648.      *                              After which an OverflowException is thrown.
  649.      *
  650.      * @throws \OverflowException When no valid value can be found by iterating $maxRetries times
  651.      *
  652.      * @return self A proxy class returning only valid values
  653.      */
  654.     public function valid(?\Closure $validator nullint $maxRetries 10000)
  655.     {
  656.         return new ValidGenerator($this$validator$maxRetries);
  657.     }
  658.     public function seed($seed null)
  659.     {
  660.         if ($seed === null) {
  661.             mt_srand();
  662.         } else {
  663.             mt_srand((int) $seedMT_RAND_PHP);
  664.         }
  665.     }
  666.     public function format($format$arguments = [])
  667.     {
  668.         return call_user_func_array($this->getFormatter($format), $arguments);
  669.     }
  670.     /**
  671.      * @param string $format
  672.      *
  673.      * @return callable
  674.      */
  675.     public function getFormatter($format)
  676.     {
  677.         if (isset($this->formatters[$format])) {
  678.             return $this->formatters[$format];
  679.         }
  680.         if (method_exists($this$format)) {
  681.             $this->formatters[$format] = [$this$format];
  682.             return $this->formatters[$format];
  683.         }
  684.         // "Faker\Core\Barcode->ean13"
  685.         if (preg_match('|^([a-zA-Z0-9\\\]+)->([a-zA-Z0-9]+)$|'$format$matches)) {
  686.             $this->formatters[$format] = [$this->ext($matches[1]), $matches[2]];
  687.             return $this->formatters[$format];
  688.         }
  689.         foreach ($this->providers as $provider) {
  690.             if (method_exists($provider$format)) {
  691.                 $this->formatters[$format] = [$provider$format];
  692.                 return $this->formatters[$format];
  693.             }
  694.         }
  695.         throw new \InvalidArgumentException(sprintf('Unknown format "%s"'$format));
  696.     }
  697.     /**
  698.      * Replaces tokens ('{{ tokenName }}') with the result from the token method call
  699.      *
  700.      * @param string $string String that needs to bet parsed
  701.      *
  702.      * @return string
  703.      */
  704.     public function parse($string)
  705.     {
  706.         $callback = function ($matches) {
  707.             return $this->format($matches[1]);
  708.         };
  709.         return preg_replace_callback('/{{\s?(\w+|[\w\\\]+->\w+?)\s?}}/u'$callback$string);
  710.     }
  711.     /**
  712.      * Get a random MIME type
  713.      *
  714.      * @example 'video/avi'
  715.      */
  716.     public function mimeType()
  717.     {
  718.         return $this->ext(Extension\FileExtension::class)->mimeType();
  719.     }
  720.     /**
  721.      * Get a random file extension (without a dot)
  722.      *
  723.      * @example avi
  724.      */
  725.     public function fileExtension()
  726.     {
  727.         return $this->ext(Extension\FileExtension::class)->extension();
  728.     }
  729.     /**
  730.      * Get a full path to a new real file on the system.
  731.      */
  732.     public function filePath()
  733.     {
  734.         return $this->ext(Extension\FileExtension::class)->filePath();
  735.     }
  736.     /**
  737.      * Get an actual blood type
  738.      *
  739.      * @example 'AB'
  740.      */
  741.     public function bloodType(): string
  742.     {
  743.         return $this->ext(Extension\BloodExtension::class)->bloodType();
  744.     }
  745.     /**
  746.      * Get a random resis value
  747.      *
  748.      * @example '+'
  749.      */
  750.     public function bloodRh(): string
  751.     {
  752.         return $this->ext(Extension\BloodExtension::class)->bloodRh();
  753.     }
  754.     /**
  755.      * Get a full blood group
  756.      *
  757.      * @example 'AB+'
  758.      */
  759.     public function bloodGroup(): string
  760.     {
  761.         return $this->ext(Extension\BloodExtension::class)->bloodGroup();
  762.     }
  763.     /**
  764.      * Get a random EAN13 barcode.
  765.      *
  766.      * @example '4006381333931'
  767.      */
  768.     public function ean13(): string
  769.     {
  770.         return $this->ext(Extension\BarcodeExtension::class)->ean13();
  771.     }
  772.     /**
  773.      * Get a random EAN8 barcode.
  774.      *
  775.      * @example '73513537'
  776.      */
  777.     public function ean8(): string
  778.     {
  779.         return $this->ext(Extension\BarcodeExtension::class)->ean8();
  780.     }
  781.     /**
  782.      * Get a random ISBN-10 code
  783.      *
  784.      * @see http://en.wikipedia.org/wiki/International_Standard_Book_Number
  785.      *
  786.      * @example '4881416324'
  787.      */
  788.     public function isbn10(): string
  789.     {
  790.         return $this->ext(Extension\BarcodeExtension::class)->isbn10();
  791.     }
  792.     /**
  793.      * Get a random ISBN-13 code
  794.      *
  795.      * @see http://en.wikipedia.org/wiki/International_Standard_Book_Number
  796.      *
  797.      * @example '9790404436093'
  798.      */
  799.     public function isbn13(): string
  800.     {
  801.         return $this->ext(Extension\BarcodeExtension::class)->isbn13();
  802.     }
  803.     /**
  804.      * Returns a random number between $int1 and $int2 (any order)
  805.      *
  806.      * @example 79907610
  807.      */
  808.     public function numberBetween($int1 0$int2 2147483647): int
  809.     {
  810.         return $this->ext(Extension\NumberExtension::class)->numberBetween((int) $int1, (int) $int2);
  811.     }
  812.     /**
  813.      * Returns a random number between 0 and 9
  814.      */
  815.     public function randomDigit(): int
  816.     {
  817.         return $this->ext(Extension\NumberExtension::class)->randomDigit();
  818.     }
  819.     /**
  820.      * Generates a random digit, which cannot be $except
  821.      */
  822.     public function randomDigitNot($except): int
  823.     {
  824.         return $this->ext(Extension\NumberExtension::class)->randomDigitNot((int) $except);
  825.     }
  826.     /**
  827.      * Returns a random number between 1 and 9
  828.      */
  829.     public function randomDigitNotZero(): int
  830.     {
  831.         return $this->ext(Extension\NumberExtension::class)->randomDigitNotZero();
  832.     }
  833.     /**
  834.      * Return a random float number
  835.      *
  836.      * @example 48.8932
  837.      */
  838.     public function randomFloat($nbMaxDecimals null$min 0$max null): float
  839.     {
  840.         return $this->ext(Extension\NumberExtension::class)->randomFloat(
  841.             $nbMaxDecimals !== null ? (int) $nbMaxDecimals null,
  842.             (float) $min,
  843.             $max !== null ? (float) $max null
  844.         );
  845.     }
  846.     /**
  847.      * Returns a random integer with 0 to $nbDigits digits.
  848.      *
  849.      * The maximum value returned is mt_getrandmax()
  850.      *
  851.      * @param int|null $nbDigits Defaults to a random number between 1 and 9
  852.      * @param bool     $strict   Whether the returned number should have exactly $nbDigits
  853.      *
  854.      * @example 79907610
  855.      */
  856.     public function randomNumber($nbDigits null$strict false): int
  857.     {
  858.         return $this->ext(Extension\NumberExtension::class)->randomNumber(
  859.             $nbDigits !== null ? (int) $nbDigits null,
  860.             (bool) $strict
  861.         );
  862.     }
  863.     /**
  864.      * Get a version number in semantic versioning syntax 2.0.0. (https://semver.org/spec/v2.0.0.html)
  865.      *
  866.      * @param bool $preRelease Pre release parts may be randomly included
  867.      * @param bool $build      Build parts may be randomly included
  868.      *
  869.      * @example 1.0.0
  870.      * @example 1.0.0-alpha.1
  871.      * @example 1.0.0-alpha.1+b71f04d
  872.      */
  873.     public function semver(bool $preRelease falsebool $build false): string
  874.     {
  875.         return $this->ext(Extension\VersionExtension::class)->semver($preRelease$build);
  876.     }
  877.     /**
  878.      * @deprecated
  879.      */
  880.     protected function callFormatWithMatches($matches)
  881.     {
  882.         trigger_deprecation('fakerphp/faker''1.14''Protected method "callFormatWithMatches()" is deprecated and will be removed.');
  883.         return $this->format($matches[1]);
  884.     }
  885.     /**
  886.      * @param string $attribute
  887.      *
  888.      * @deprecated Use a method instead.
  889.      */
  890.     public function __get($attribute)
  891.     {
  892.         trigger_deprecation('fakerphp/faker''1.14''Accessing property "%s" is deprecated, use "%s()" instead.'$attribute$attribute);
  893.         return $this->format($attribute);
  894.     }
  895.     /**
  896.      * @param string $method
  897.      * @param array  $attributes
  898.      */
  899.     public function __call($method$attributes)
  900.     {
  901.         return $this->format($method$attributes);
  902.     }
  903.     public function __destruct()
  904.     {
  905.         $this->seed();
  906.     }
  907.     public function __wakeup()
  908.     {
  909.         $this->formatters = [];
  910.     }
  911. }