Skip to content

Commit

Permalink
Merge pull request #28 from icfr/icfr-patch-1
Browse files Browse the repository at this point in the history
Use default Application locale as country if none provided
  • Loading branch information
Propaganistas committed Apr 6, 2016
2 parents c08f344 + 33e188b commit 05371ff
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
* @param int|null $format
* @return string
*/
function phone_format($phone, $country, $format = PhoneNumberFormat::INTERNATIONAL)
{
$lib = App::make('libphonenumber');
$phoneNumber = $lib->parse($phone, $country);
function phone_format($phone, $country = null, $format = PhoneNumberFormat::INTERNATIONAL)
{
$lib = App::make('libphonenumber');

return $lib->format($phoneNumber, $format);
}
if (!$country) {
$country = App::getLocale();
}

$phoneNumber = $lib->parse($phone, $country);

return $lib->format($phoneNumber, $format);
}
}

0 comments on commit 05371ff

Please sign in to comment.