alpixel / phoneformatterbundle
Provides helper to format phone number easily
Installs: 24
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.4.0
- giggsey/libphonenumber-for-php: ^7.7
- symfony/symfony: ~2.8|~3.0
This package is not auto-updated.
Last update: 2024-11-09 20:56:16 UTC
README
Installation
- Install the package
composer require 'alpixel/phoneformatterbundle'
- Update AppKernel.php
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Alpixel\Bundle\PhoneFormatterBundle\AlpixelPhoneFormatterBundle(),
);
// ...
}
// ...
}
Utilisation
Helper
The only helper actually available give you the possibility to reformat and clean a phone number following a pattern.
You can call the helper this way
$number = $this->get('alpixel.helper.phone_formatter')->format($currentNumber, PhoneNumberFormat::NATIONAL, 'DE');
The example above will try to output a national german number from the input you gave.
The format option can be :
AlpixelPhoneNumberFormat::INTERNATIONAL // example "+41 44 668 18 00"
AlpixelPhoneNumberFormat::NATIONAL // example : "044 668 18 00"
AlpixelPhoneNumberFormat::E164 // example : "+41446681800"
AlpixelPhoneNumberFormat::AUTO // Will try to make the best guess from your current locale
The third argument is expecting a two letter country code as FR or DE
Twig extension
The helper is callable via a twig extension like this :
"03 03 03 03 03"|phone_format("INTERNATIONAL", "FR")
"03 03 03 03 03"|phone_format("NATIONAL")
"03 03 03 03 03"|phone_format("AUTO", "CH")