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