slimdump
slimdump copied to clipboard
Allow calling faker methods with arguments
This PR adds the ability to call more complex faker methods.
It follows an easy convention: FAKER_methodName:arguments
The arguments of the faker method can be separated by a comma.
Examples:
<?xml version="1.0" ?>
<slimdump>
<table name="users" dump="full">
<column name="username" dump="replace" replacement="FAKER_word" />
<column name="password" dump="replace" replacement="test" />
<column name="amount" dump="replace" replacement="FAKER_numberBetween:1,100" />
<column name="lastname" dump="replace" replacement="FAKER_numerify:'Helo ###'" />
<column name="email" dump="replace" replacement="FAKER_unique->randomDigitNot:0" />
</table>
</slimdump>
Edit: I haven't changed the README yet, as I wasn't sure if you want this PR. If this gets merged, I can prepare a PR that modifies the documentation.
This is indeed a nice addition to the featureset of slimdump!
Are there any reasons to not use parantheses here (like FAKER_unique->randomDigitNot(0)
)? I think the closer we stay to the PHP syntax the better, as this removed the mental load of translating the Faker documentation into our own syntax.