diff --git a/.gitignore b/.gitignore index 3e99efa..153f9b1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ /phpstan.neon /phpunit.xml /vendor/ -test_db \ No newline at end of file +test_db +/test +/test_ db.sqlite diff --git a/README.md b/README.md index e6af68f..77f3fb2 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,16 @@ This pack provides: * `fr-fr.address`: Same as address from core but with a sample of 500 dumb french addresses * `fr-fr.firstname`: Anonymize with a random french first names from a sample of ~500 items * `fr-fr.lastname`: Anonymize with a random french last names from a sample of ~500 items -* `fr-fr.phone`: Anonymize french telephone numbers, (only option is `mode`: `mobile` or `landline` +* `fr-fr.phone`: Anonymize french telephone numbers, (only option is `mode`: `mobile` or `landline`) +* `fr-fr.secu`: Anonymize french social sécurity numbers +* `fr-fr.cb` : Anonymize credit card numbers with a sample of 40 items ## Installation Run the following command to add this pack to your application: ```sh -composer require db-tools-bundle/pack-fr-fr +composer require dbtoolsbundle/pack-fr-fr ``` Learn more about how to use this package reading [the DbToolsBundle documentation](https://dbtoolsbundle.readthedocs.io/) on Read the Docs. diff --git a/src/Anonymizer/CreditCardNumberAnonymizer.php b/src/Anonymizer/CreditCardNumberAnonymizer.php new file mode 100644 index 0000000..e90e404 --- /dev/null +++ b/src/Anonymizer/CreditCardNumberAnonymizer.php @@ -0,0 +1,70 @@ +expression(); + + + $update->set( + $this->columnName, + $this->getSetIfNotNullExpression( + $expr->concat( + $expr->lpad($this->getRandomIntExpression(4), 1, '0'), + $expr->lpad($this->getRandomIntExpression(9), 1, '0'), + $expr->lpad($this->getRandomIntExpression(9), 1, '0'), + //The 13 corresponds to the 4th and 5th characters, which represent the month of the year. However, 13 is not a valid month, so this would not be a valid social security number. + '13', + $expr->lpad($this->getRandomIntExpression(999999999), 10, '0'), + + ) + ) + ); + + + } +} +