Smile-SA / gdpr-dump

Utility that creates anonymized database dumps (MySQL only). Provides default config templates for Magento, Drupal and Shopware.
GNU General Public License v3.0
182 stars 47 forks source link

custom callables converters #107

Closed staabm closed 8 months ago

staabm commented 8 months ago

Is your feature request related to a problem? Please describe. we are happily using the faker provided data to anonymize our data. the currently existing faker-converter supports all faker methods which are supported on the Generator class.

we tried

  mytable:
    converters:
        mycol:
            converter: 'faker' 
            parameters:
                formatter: 'bank' 

but this didn't work

Unknown format "bank"

The fakers Generator class supports only a subset of Faker's actual functionality though. e.g. there are static methods on some Provider classes which are not callable via the Generator proxy class.

it would be great if we could make use of all available fake data in the Faker library

Describe the solution you'd like I think one common solution to the problem would be a converter type, which allows to call any PHP callable. this could e.g. look like

  mytable:
    converters:
        mycol:
            converter: 'callable' 
            parameters:
                name: '\Faker\Provider\de_DE\Payment::bank'

at the same time this formatter could be used to call any php function contained in php-src:

  mytable:
    converters:
        mycol:
            converter: 'callable' 
            parameters:
                name: 'str_repeat'
                arguments: ['test', 3]

Describe alternatives you've considered

Additional context

guvra commented 8 months ago

Hi,

Actually the issue is that the bank formatter is only available with the de_DE locale. The phar file provided in the releases section is only bundled with the en_US locale (the phar file would be too big if it included all faker locales).

You need to manually compile a phar file that bundles the de_DE locale. The wiki explains how to do this.