Created
February 7, 2019 14:36
-
-
Save pierreboissinot/7110388b7cdc7def23191a4c5ebc2ec1 to your computer and use it in GitHub Desktop.
PhoneNumber Faker Provider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// AliceBundle: https://github.com/hautelook/AliceBundle/blob/master/doc/faker-providers.md | |
// https://github.com/misd-service-development/phone-number-bundle/issues/27 | |
// Usage: <PhoneNumber()> | |
namespace App\DataFixtures\Faker\Provider; | |
use Faker\Factory; | |
use libphonenumber\PhoneNumberUtil; | |
class PhoneNumberProvider | |
{ | |
/** | |
* @var PhoneNumberUtil | |
*/ | |
private $phoneNumberUtil; | |
public function __construct(PhoneNumberUtil $phoneNumberUtil) | |
{ | |
$this->phoneNumberUtil = $phoneNumberUtil; | |
} | |
public function PhoneNumber() | |
{ | |
$faker = Factory::create('fr'); | |
return $this->phoneNumberUtil->parse($faker->phoneNumber, 'FR'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment