@@ -5,66 +5,66 @@ |
||
| 5 | 5 | use Illuminate\Support\Facades\Validator; |
| 6 | 6 | |
| 7 | 7 | if (! function_exists('phone')) { |
| 8 | - /** |
|
| 9 | - * Get the PhoneNumberUtil or format a phone number for display. |
|
| 10 | - * |
|
| 11 | - * @return \libphonenumber\PhoneNumberUtil|string |
|
| 12 | - */ |
|
| 13 | - function phone() |
|
| 14 | - { |
|
| 15 | - $lib = App::make('libphonenumber'); |
|
| 8 | + /** |
|
| 9 | + * Get the PhoneNumberUtil or format a phone number for display. |
|
| 10 | + * |
|
| 11 | + * @return \libphonenumber\PhoneNumberUtil|string |
|
| 12 | + */ |
|
| 13 | + function phone() |
|
| 14 | + { |
|
| 15 | + $lib = App::make('libphonenumber'); |
|
| 16 | 16 | |
| 17 | - if (! $arguments = func_get_args()) { |
|
| 18 | - return $lib; |
|
| 19 | - } |
|
| 17 | + if (! $arguments = func_get_args()) { |
|
| 18 | + return $lib; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - $phone = $arguments[0]; |
|
| 21 | + $phone = $arguments[0]; |
|
| 22 | 22 | |
| 23 | - $countries = isset($arguments[1]) ? (is_array($arguments[1]) ? $arguments[1] : [$arguments[1]]) : []; |
|
| 23 | + $countries = isset($arguments[1]) ? (is_array($arguments[1]) ? $arguments[1] : [$arguments[1]]) : []; |
|
| 24 | 24 | |
| 25 | - $format = isset($arguments[2]) ? $arguments[2] : PhoneNumberFormat::INTERNATIONAL; |
|
| 25 | + $format = isset($arguments[2]) ? $arguments[2] : PhoneNumberFormat::INTERNATIONAL; |
|
| 26 | 26 | |
| 27 | - $validator = null; |
|
| 27 | + $validator = null; |
|
| 28 | 28 | |
| 29 | - for($i = 0; $i < sizeof($countries); $i++) |
|
| 30 | - { |
|
| 31 | - if($countries[$i] === null) |
|
| 32 | - { |
|
| 33 | - return $lib->format( |
|
| 34 | - $lib->parse($phone, App::getLocale()), |
|
| 35 | - $format |
|
| 36 | - ); |
|
| 37 | - } |
|
| 29 | + for($i = 0; $i < sizeof($countries); $i++) |
|
| 30 | + { |
|
| 31 | + if($countries[$i] === null) |
|
| 32 | + { |
|
| 33 | + return $lib->format( |
|
| 34 | + $lib->parse($phone, App::getLocale()), |
|
| 35 | + $format |
|
| 36 | + ); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - $validator = Validator::make(['phone' => $phone], [ |
|
| 40 | - 'phone' => 'required|phone:' . $countries[$i], |
|
| 41 | - ]); |
|
| 39 | + $validator = Validator::make(['phone' => $phone], [ |
|
| 40 | + 'phone' => 'required|phone:' . $countries[$i], |
|
| 41 | + ]); |
|
| 42 | 42 | |
| 43 | - if (!$validator->fails()) { |
|
| 44 | - return $lib->format( |
|
| 45 | - $lib->parse($phone, $countries[$i]), |
|
| 46 | - $format |
|
| 47 | - ); |
|
| 48 | - } |
|
| 49 | - } |
|
| 43 | + if (!$validator->fails()) { |
|
| 44 | + return $lib->format( |
|
| 45 | + $lib->parse($phone, $countries[$i]), |
|
| 46 | + $format |
|
| 47 | + ); |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - return $lib; |
|
| 52 | - } |
|
| 51 | + return $lib; |
|
| 52 | + } |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | if (! function_exists('phone_format')) { |
| 56 | - /** |
|
| 57 | - * Formats a phone number and country for display. |
|
| 58 | - * |
|
| 59 | - * @param string $phone |
|
| 60 | - * @param string|string[] $countries |
|
| 61 | - * @param int|null $format |
|
| 62 | - * @return string |
|
| 63 | - * |
|
| 64 | - * @deprecated 2.8.0 |
|
| 65 | - */ |
|
| 66 | - function phone_format($phone, $countries = null, $format = PhoneNumberFormat::INTERNATIONAL) |
|
| 67 | - { |
|
| 68 | - return phone($phone, $countries, $format); |
|
| 69 | - } |
|
| 56 | + /** |
|
| 57 | + * Formats a phone number and country for display. |
|
| 58 | + * |
|
| 59 | + * @param string $phone |
|
| 60 | + * @param string|string[] $countries |
|
| 61 | + * @param int|null $format |
|
| 62 | + * @return string |
|
| 63 | + * |
|
| 64 | + * @deprecated 2.8.0 |
|
| 65 | + */ |
|
| 66 | + function phone_format($phone, $countries = null, $format = PhoneNumberFormat::INTERNATIONAL) |
|
| 67 | + { |
|
| 68 | + return phone($phone, $countries, $format); |
|
| 69 | + } |
|
| 70 | 70 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | use libphonenumber\PhoneNumberFormat; |
| 5 | 5 | use Illuminate\Support\Facades\Validator; |
| 6 | 6 | |
| 7 | -if (! function_exists('phone')) { |
|
| 7 | +if (!function_exists('phone')) { |
|
| 8 | 8 | /** |
| 9 | 9 | * Get the PhoneNumberUtil or format a phone number for display. |
| 10 | 10 | * |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | { |
| 15 | 15 | $lib = App::make('libphonenumber'); |
| 16 | 16 | |
| 17 | - if (! $arguments = func_get_args()) { |
|
| 17 | + if (!$arguments = func_get_args()) { |
|
| 18 | 18 | return $lib; |
| 19 | 19 | } |
| 20 | 20 | |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | $validator = null; |
| 28 | 28 | |
| 29 | - for($i = 0; $i < sizeof($countries); $i++) |
|
| 29 | + for ($i = 0; $i < sizeof($countries); $i++) |
|
| 30 | 30 | { |
| 31 | - if($countries[$i] === null) |
|
| 31 | + if ($countries[$i] === null) |
|
| 32 | 32 | { |
| 33 | 33 | return $lib->format( |
| 34 | 34 | $lib->parse($phone, App::getLocale()), |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $validator = Validator::make(['phone' => $phone], [ |
| 40 | - 'phone' => 'required|phone:' . $countries[$i], |
|
| 40 | + 'phone' => 'required|phone:'.$countries[$i], |
|
| 41 | 41 | ]); |
| 42 | 42 | |
| 43 | 43 | if (!$validator->fails()) { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | -if (! function_exists('phone_format')) { |
|
| 55 | +if (!function_exists('phone_format')) { |
|
| 56 | 56 | /** |
| 57 | 57 | * Formats a phone number and country for display. |
| 58 | 58 | * |