@@ -142,11 +142,11 @@ |
||
142 | 142 | $parameters = implode(',', array_merge( |
143 | 143 | $this->countries, |
144 | 144 | static::parseTypes($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 | } |
@@ -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 | } |
@@ -7,74 +7,74 @@ |
||
7 | 7 | |
8 | 8 | trait ParsesTypes |
9 | 9 | { |
10 | - /** |
|
11 | - * Array of available phone types. |
|
12 | - * |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - protected static $resolvedTypes; |
|
10 | + /** |
|
11 | + * Array of available phone types. |
|
12 | + * |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + protected static $resolvedTypes; |
|
16 | 16 | |
17 | - /** |
|
18 | - * Determine whether the given type is valid. |
|
19 | - * |
|
20 | - * @param string $type |
|
21 | - * @return bool |
|
22 | - */ |
|
23 | - public static function isValidType($type) |
|
24 | - { |
|
25 | - return ! empty(static::parseTypes($type)); |
|
26 | - } |
|
17 | + /** |
|
18 | + * Determine whether the given type is valid. |
|
19 | + * |
|
20 | + * @param string $type |
|
21 | + * @return bool |
|
22 | + */ |
|
23 | + public static function isValidType($type) |
|
24 | + { |
|
25 | + return ! empty(static::parseTypes($type)); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Parse a phone type into constant's value. |
|
30 | - * |
|
31 | - * @param string|array $types |
|
32 | - * @return array |
|
33 | - */ |
|
34 | - protected static function parseTypes($types) |
|
35 | - { |
|
36 | - static::loadTypes(); |
|
28 | + /** |
|
29 | + * Parse a phone type into constant's value. |
|
30 | + * |
|
31 | + * @param string|array $types |
|
32 | + * @return array |
|
33 | + */ |
|
34 | + protected static function parseTypes($types) |
|
35 | + { |
|
36 | + static::loadTypes(); |
|
37 | 37 | |
38 | - return Collection::make(is_array($types) ? $types : func_get_args()) |
|
39 | - ->map(function ($type) { |
|
40 | - // If the type equals a constant's value, just return it. |
|
41 | - if (is_numeric($type) && in_array($type, static::$resolvedTypes)) { |
|
42 | - return (int) $type; |
|
43 | - } |
|
38 | + return Collection::make(is_array($types) ? $types : func_get_args()) |
|
39 | + ->map(function ($type) { |
|
40 | + // If the type equals a constant's value, just return it. |
|
41 | + if (is_numeric($type) && in_array($type, static::$resolvedTypes)) { |
|
42 | + return (int) $type; |
|
43 | + } |
|
44 | 44 | |
45 | - // Otherwise we'll assume the type is the constant's name. |
|
46 | - return Arr::get(static::$resolvedTypes, strtoupper($type)); |
|
47 | - }) |
|
48 | - ->reject(function ($value) { |
|
49 | - return is_null($value) || $value === false; |
|
50 | - })->toArray(); |
|
51 | - } |
|
45 | + // Otherwise we'll assume the type is the constant's name. |
|
46 | + return Arr::get(static::$resolvedTypes, strtoupper($type)); |
|
47 | + }) |
|
48 | + ->reject(function ($value) { |
|
49 | + return is_null($value) || $value === false; |
|
50 | + })->toArray(); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Parse a phone type into its string representation. |
|
55 | - * |
|
56 | - * @param string|array $types |
|
57 | - * @return array |
|
58 | - */ |
|
59 | - protected static function parseTypesAsStrings($types) |
|
60 | - { |
|
61 | - static::loadTypes(); |
|
53 | + /** |
|
54 | + * Parse a phone type into its string representation. |
|
55 | + * |
|
56 | + * @param string|array $types |
|
57 | + * @return array |
|
58 | + */ |
|
59 | + protected static function parseTypesAsStrings($types) |
|
60 | + { |
|
61 | + static::loadTypes(); |
|
62 | 62 | |
63 | - return array_keys( |
|
64 | - array_intersect( |
|
65 | - static::$resolvedTypes, |
|
66 | - static::parseTypes($types) |
|
67 | - ) |
|
68 | - ); |
|
69 | - } |
|
63 | + return array_keys( |
|
64 | + array_intersect( |
|
65 | + static::$resolvedTypes, |
|
66 | + static::parseTypes($types) |
|
67 | + ) |
|
68 | + ); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Load all available formats once. |
|
73 | - */ |
|
74 | - private static function loadTypes() |
|
75 | - { |
|
76 | - if (! static::$resolvedTypes) { |
|
77 | - static::$resolvedTypes = with(new ReflectionClass(PhoneNumberType::class))->getConstants(); |
|
78 | - } |
|
79 | - } |
|
71 | + /** |
|
72 | + * Load all available formats once. |
|
73 | + */ |
|
74 | + private static function loadTypes() |
|
75 | + { |
|
76 | + if (! static::$resolvedTypes) { |
|
77 | + static::$resolvedTypes = with(new ReflectionClass(PhoneNumberType::class))->getConstants(); |
|
78 | + } |
|
79 | + } |
|
80 | 80 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public static function isValidType($type) |
24 | 24 | { |
25 | - return ! empty(static::parseTypes($type)); |
|
25 | + return !empty(static::parseTypes($type)); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | static::loadTypes(); |
37 | 37 | |
38 | 38 | return Collection::make(is_array($types) ? $types : func_get_args()) |
39 | - ->map(function ($type) { |
|
39 | + ->map(function($type) { |
|
40 | 40 | // If the type equals a constant's value, just return it. |
41 | 41 | if (is_numeric($type) && in_array($type, static::$resolvedTypes)) { |
42 | 42 | return (int) $type; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | // Otherwise we'll assume the type is the constant's name. |
46 | 46 | return Arr::get(static::$resolvedTypes, strtoupper($type)); |
47 | 47 | }) |
48 | - ->reject(function ($value) { |
|
48 | + ->reject(function($value) { |
|
49 | 49 | return is_null($value) || $value === false; |
50 | 50 | })->toArray(); |
51 | 51 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | private static function loadTypes() |
75 | 75 | { |
76 | - if (! static::$resolvedTypes) { |
|
76 | + if (!static::$resolvedTypes) { |
|
77 | 77 | static::$resolvedTypes = with(new ReflectionClass(PhoneNumberType::class))->getConstants(); |
78 | 78 | } |
79 | 79 | } |