Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

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