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\Provider\fr_FR;
4
 
5
class PhoneNumber extends \Faker\Provider\PhoneNumber
6
{
7
    // Phone numbers can't start by 00 in France
8
    // 01 is the most common prefix
9
    protected static $formats = [
10
        '+33 (0)1 ## ## ## ##',
11
        '+33 (0)1 ## ## ## ##',
12
        '+33 (0)2 ## ## ## ##',
13
        '+33 (0)3 ## ## ## ##',
14
        '+33 (0)4 ## ## ## ##',
15
        '+33 (0)5 ## ## ## ##',
16
        '+33 (0)6 ## ## ## ##',
17
        '+33 (0)7 {{phoneNumber07WithSeparator}}',
18
        '+33 (0)8 {{phoneNumber08WithSeparator}}',
19
        '+33 (0)9 ## ## ## ##',
20
        '+33 1 ## ## ## ##',
21
        '+33 1 ## ## ## ##',
22
        '+33 2 ## ## ## ##',
23
        '+33 3 ## ## ## ##',
24
        '+33 4 ## ## ## ##',
25
        '+33 5 ## ## ## ##',
26
        '+33 6 ## ## ## ##',
27
        '+33 7 {{phoneNumber07WithSeparator}}',
28
        '+33 8 {{phoneNumber08WithSeparator}}',
29
        '+33 9 ## ## ## ##',
30
        '01########',
31
        '01########',
32
        '02########',
33
        '03########',
34
        '04########',
35
        '05########',
36
        '06########',
37
        '07{{phoneNumber07}}',
38
        '08{{phoneNumber08}}',
39
        '09########',
40
        '01 ## ## ## ##',
41
        '01 ## ## ## ##',
42
        '02 ## ## ## ##',
43
        '03 ## ## ## ##',
44
        '04 ## ## ## ##',
45
        '05 ## ## ## ##',
46
        '06 ## ## ## ##',
47
        '07 {{phoneNumber07WithSeparator}}',
48
        '08 {{phoneNumber08WithSeparator}}',
49
        '09 ## ## ## ##',
50
    ];
51
 
52
    // Mobile phone numbers start by 06 and 07
53
    // 06 is the most common prefix
54
    protected static $mobileFormats = [
55
        '+33 (0)6 ## ## ## ##',
56
        '+33 6 ## ## ## ##',
57
        '+33 (0)7 {{phoneNumber07WithSeparator}}',
58
        '+33 7 {{phoneNumber07WithSeparator}}',
59
        '06########',
60
        '07{{phoneNumber07}}',
61
        '06 ## ## ## ##',
62
        '07 {{phoneNumber07WithSeparator}}',
63
    ];
64
 
65
    protected static $serviceFormats = [
66
        '+33 (0)8 {{phoneNumber08WithSeparator}}',
67
        '+33 8 {{phoneNumber08WithSeparator}}',
68
        '08 {{phoneNumber08WithSeparator}}',
69
        '08{{phoneNumber08}}',
70
    ];
71
 
72
    protected static $e164Formats = [
73
        '+33#########',
74
    ];
75
 
76
    public function phoneNumber07()
77
    {
78
        $phoneNumber = $this->phoneNumber07WithSeparator();
79
 
80
        return str_replace(' ', '', $phoneNumber);
81
    }
82
 
83
    /**
84
     * Only 073 to 079 are acceptable prefixes with 07
85
     *
86
     * @see http://www.arcep.fr/index.php?id=8146
87
     */
88
    public function phoneNumber07WithSeparator()
89
    {
90
        $phoneNumber = $this->generator->numberBetween(3, 9);
91
        $phoneNumber .= $this->numerify('# ## ## ##');
92
 
93
        return $phoneNumber;
94
    }
95
 
96
    public function phoneNumber08()
97
    {
98
        $phoneNumber = $this->phoneNumber08WithSeparator();
99
 
100
        return str_replace(' ', '', $phoneNumber);
101
    }
102
 
103
    /**
104
     *  Valid formats for 08:
105
     *
106
     *  0# ## ## ##
107
     *  1# ## ## ##
108
     *  2# ## ## ##
109
     *  91 ## ## ##
110
     *  92 ## ## ##
111
     *  93 ## ## ##
112
     *  97 ## ## ##
113
     *  98 ## ## ##
114
     *  99 ## ## ##
115
     *
116
     *  Formats 089(4|6)## ## ## are valid, but will be
117
     *  attributed when other 089 resource ranges are exhausted.
118
     *
119
     * @see https://www.arcep.fr/index.php?id=8146#c9625
120
     * @see https://issuetracker.google.com/u/1/issues/73269839
121
     */
122
    public function phoneNumber08WithSeparator()
123
    {
124
        $regex = '([012]{1}\d{1}|(9[1-357-9])( \d{2}){3}';
125
 
126
        return $this->regexify($regex);
127
    }
128
 
129
    /**
130
     * @example '0601020304'
131
     */
132
    public function mobileNumber()
133
    {
134
        $format = static::randomElement(static::$mobileFormats);
135
 
136
        return static::numerify($this->generator->parse($format));
137
    }
138
 
139
    /**
140
     * @example '0891951357'
141
     */
142
    public function serviceNumber()
143
    {
144
        $format = static::randomElement(static::$serviceFormats);
145
 
146
        return static::numerify($this->generator->parse($format));
147
    }
148
}