From 055f4e9e8bb96363cc75333ad97452ae1957efd8 Mon Sep 17 00:00:00 2001 From: Geoffrey Brier <geoffrey@widop.com> Date: Tue, 5 Jun 2012 21:22:25 +0200 Subject: [PATCH] Added siren and siret formatters (fr_FR) --- src/Faker/Provider/fr_FR/Company.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Faker/Provider/fr_FR/Company.php b/src/Faker/Provider/fr_FR/Company.php index 7e3cf92f..fe7d326f 100644 --- a/src/Faker/Provider/fr_FR/Company.php +++ b/src/Faker/Provider/fr_FR/Company.php @@ -12,4 +12,22 @@ class Company extends \Faker\Provider\Company ); protected static $companySuffix = array('SA', 'S.A.', 'SARL', 'S.A.R.L.', 'S.A.S.'); + + protected static $sirenFormat = "### ### ###"; + + public static function siret($maxSequentialDigits = 2) + { + if ($maxSequentialDigits > 4 || $maxSequentialDigits <= 0) { + $maxSequentialDigits = 2; + } + + $sequentialNumber = str_pad(static::randomNumber($maxSequentialDigits), 4, '0', STR_PAD_LEFT); + + return static::numerify(static::siren() . ' ' . $sequentialNumber . '#'); + } + + public static function siren() + { + return static::numerify(static::$sirenFormat); + } } \ No newline at end of file