@@ -6,149 +6,149 @@ |
||
6 | 6 | |
7 | 7 | class Phone |
8 | 8 | { |
9 | - use ParsesTypes; |
|
9 | + use ParsesTypes; |
|
10 | 10 | |
11 | - /** |
|
12 | - * The provided phone countries. |
|
13 | - * |
|
14 | - * @var array |
|
15 | - */ |
|
16 | - protected $countries = []; |
|
17 | - |
|
18 | - /** |
|
19 | - * The input field name to check for a country value. |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $countryField; |
|
24 | - |
|
25 | - /** |
|
26 | - * The provided phone types. |
|
27 | - * |
|
28 | - * @var array |
|
29 | - */ |
|
30 | - protected $types = []; |
|
31 | - |
|
32 | - /** |
|
33 | - * Whether the number's country should be auto-detected. |
|
34 | - * |
|
35 | - * @var bool |
|
36 | - */ |
|
37 | - protected $detect = false; |
|
38 | - |
|
39 | - /** |
|
40 | - * Whether to allow lenient checks (i.e. landline numbers without area codes). |
|
41 | - * |
|
42 | - * @var bool |
|
43 | - */ |
|
44 | - protected $lenient = false; |
|
45 | - |
|
46 | - /** |
|
47 | - * Set the phone countries. |
|
48 | - * |
|
49 | - * @param string|array $country |
|
50 | - * @return $this |
|
51 | - */ |
|
52 | - public function country($country) |
|
53 | - { |
|
54 | - $countries = is_array($country) ? $country : func_get_args(); |
|
55 | - |
|
56 | - $this->countries = array_merge($this->countries, $countries); |
|
57 | - |
|
58 | - return $this; |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * Set the country input field. |
|
63 | - * |
|
64 | - * @param string $name |
|
65 | - * @return $this |
|
66 | - */ |
|
67 | - public function countryField($name) |
|
68 | - { |
|
69 | - $this->countryField = $name; |
|
70 | - |
|
71 | - return $this; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Set the phone types. |
|
76 | - * |
|
77 | - * @param string|array $type |
|
78 | - * @return $this |
|
79 | - */ |
|
80 | - public function type($type) |
|
81 | - { |
|
82 | - $types = is_array($type) ? $type : func_get_args(); |
|
83 | - |
|
84 | - $this->types = array_merge($this->types, $types); |
|
85 | - |
|
86 | - return $this; |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * Shortcut method for mobile type restriction. |
|
91 | - * |
|
92 | - * @return $this |
|
93 | - */ |
|
94 | - public function mobile() |
|
95 | - { |
|
96 | - $this->type(PhoneNumberType::MOBILE); |
|
97 | - |
|
98 | - return $this; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * Shortcut method for fixed line type restriction. |
|
103 | - * |
|
104 | - * @return $this |
|
105 | - */ |
|
106 | - public function fixedLine() |
|
107 | - { |
|
108 | - $this->type(PhoneNumberType::FIXED_LINE); |
|
109 | - |
|
110 | - return $this; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Enable automatic country detection. |
|
115 | - * |
|
116 | - * @return $this |
|
117 | - */ |
|
118 | - public function detect() |
|
119 | - { |
|
120 | - $this->detect = true; |
|
121 | - |
|
122 | - return $this; |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * Enable lenient number checking. |
|
127 | - * |
|
128 | - * @return $this |
|
129 | - */ |
|
130 | - public function lenient() |
|
131 | - { |
|
132 | - $this->lenient = true; |
|
133 | - |
|
134 | - return $this; |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * Convert the rule to a validation string. |
|
139 | - * |
|
140 | - * @return string |
|
141 | - */ |
|
142 | - public function __toString() |
|
143 | - { |
|
144 | - $parameters = implode(',', array_merge( |
|
145 | - $this->countries, |
|
146 | - static::parseTypes($this->types), |
|
147 | - ($this->countryField ? [$this->countryField]: []), |
|
148 | - ($this->detect ? ['AUTO'] : []), |
|
149 | - ($this->lenient ? ['LENIENT'] : []) |
|
150 | - )); |
|
151 | - |
|
152 | - return 'phone' . (! empty($parameters) ? ":$parameters" : ''); |
|
153 | - } |
|
11 | + /** |
|
12 | + * The provided phone countries. |
|
13 | + * |
|
14 | + * @var array |
|
15 | + */ |
|
16 | + protected $countries = []; |
|
17 | + |
|
18 | + /** |
|
19 | + * The input field name to check for a country value. |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $countryField; |
|
24 | + |
|
25 | + /** |
|
26 | + * The provided phone types. |
|
27 | + * |
|
28 | + * @var array |
|
29 | + */ |
|
30 | + protected $types = []; |
|
31 | + |
|
32 | + /** |
|
33 | + * Whether the number's country should be auto-detected. |
|
34 | + * |
|
35 | + * @var bool |
|
36 | + */ |
|
37 | + protected $detect = false; |
|
38 | + |
|
39 | + /** |
|
40 | + * Whether to allow lenient checks (i.e. landline numbers without area codes). |
|
41 | + * |
|
42 | + * @var bool |
|
43 | + */ |
|
44 | + protected $lenient = false; |
|
45 | + |
|
46 | + /** |
|
47 | + * Set the phone countries. |
|
48 | + * |
|
49 | + * @param string|array $country |
|
50 | + * @return $this |
|
51 | + */ |
|
52 | + public function country($country) |
|
53 | + { |
|
54 | + $countries = is_array($country) ? $country : func_get_args(); |
|
55 | + |
|
56 | + $this->countries = array_merge($this->countries, $countries); |
|
57 | + |
|
58 | + return $this; |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * Set the country input field. |
|
63 | + * |
|
64 | + * @param string $name |
|
65 | + * @return $this |
|
66 | + */ |
|
67 | + public function countryField($name) |
|
68 | + { |
|
69 | + $this->countryField = $name; |
|
70 | + |
|
71 | + return $this; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Set the phone types. |
|
76 | + * |
|
77 | + * @param string|array $type |
|
78 | + * @return $this |
|
79 | + */ |
|
80 | + public function type($type) |
|
81 | + { |
|
82 | + $types = is_array($type) ? $type : func_get_args(); |
|
83 | + |
|
84 | + $this->types = array_merge($this->types, $types); |
|
85 | + |
|
86 | + return $this; |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * Shortcut method for mobile type restriction. |
|
91 | + * |
|
92 | + * @return $this |
|
93 | + */ |
|
94 | + public function mobile() |
|
95 | + { |
|
96 | + $this->type(PhoneNumberType::MOBILE); |
|
97 | + |
|
98 | + return $this; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Shortcut method for fixed line type restriction. |
|
103 | + * |
|
104 | + * @return $this |
|
105 | + */ |
|
106 | + public function fixedLine() |
|
107 | + { |
|
108 | + $this->type(PhoneNumberType::FIXED_LINE); |
|
109 | + |
|
110 | + return $this; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Enable automatic country detection. |
|
115 | + * |
|
116 | + * @return $this |
|
117 | + */ |
|
118 | + public function detect() |
|
119 | + { |
|
120 | + $this->detect = true; |
|
121 | + |
|
122 | + return $this; |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Enable lenient number checking. |
|
127 | + * |
|
128 | + * @return $this |
|
129 | + */ |
|
130 | + public function lenient() |
|
131 | + { |
|
132 | + $this->lenient = true; |
|
133 | + |
|
134 | + return $this; |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * Convert the rule to a validation string. |
|
139 | + * |
|
140 | + * @return string |
|
141 | + */ |
|
142 | + public function __toString() |
|
143 | + { |
|
144 | + $parameters = implode(',', array_merge( |
|
145 | + $this->countries, |
|
146 | + static::parseTypes($this->types), |
|
147 | + ($this->countryField ? [$this->countryField]: []), |
|
148 | + ($this->detect ? ['AUTO'] : []), |
|
149 | + ($this->lenient ? ['LENIENT'] : []) |
|
150 | + )); |
|
151 | + |
|
152 | + return 'phone' . (! empty($parameters) ? ":$parameters" : ''); |
|
153 | + } |
|
154 | 154 | } |