-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/add faker integration #21
Feature/add faker integration #21
Conversation
currently the vuild is failing due to ".PHP Fatal error: Class 'Faker\Factory' not found in /home/travis/build/webfactory/slimdump/src/Webfactory/Slimdump/Config/FakerReplacer.php on line 36" error. |
@franziskahahn Thanks for your effort! To speed up the build, the
and pushing it should fix the error. |
@Matthimatiker ah okay, I see.... 😅 I will also check the decreased test coverage then! |
2 similar comments
@mpdude @MalteWunsch Any objections to merge? Looks good to me. |
Only quickly skimmed the code, so possibly dumb questions: This only works for the default Faker formatters that require no arguments, and "FAKER_name" has special case handling/extra code? What would we need to change to design this in a more open way that makes it possible to use/register custom Faker formatters as well? I am asking because in the cases where we are running fixtures with Faker we came up with custom formatters pretty quickly. |
*/ | ||
public static function isFakerColumn($replacement) | ||
{ | ||
if (strpos($replacement, self::PREFIX) === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My impulse was to shorten it to return strpos($replacement, self::PREFIX) === 0;
, but that seems to be a matter of personal taste, so please go along.
|
||
/** | ||
* returns first and lastname separated by space | ||
* Please note: This method might be marked as unused in your IDE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being a fan of static code analysis, I don't really like the mapping alias => function name, resulting in the IDE marking these functions as unused. If the functions are that small, one might want to consider inlining them to the mapping, if the functions get bigger, one might want to extract classes.
But as we have only one such function so far, this is not a real issue and nothing we could reasonably decide now. Additionally, this not-real-issue is contained in the FakerReplacer, which I'm perfectly happy to see as a black box. So, everything fine with me.
@@ -62,6 +62,14 @@ public function processRowValue($value) { | |||
} | |||
|
|||
if ($this->dump == Config::REPLACE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing for this PR to care about, but I smell an emerging switch statement, which could be replaced in a more object oriented way. I haven't thought about it yet, but some kind of configurable Provider comes into mind. Depending on the solution, one might even get rid of the hard Faker dependency.
But again, this is more of a reminder for ourselves than a critique on the PR, which is fine with me. Thanks!
I've added some non-blocking suggestions/worries, but to be fair, they all relate to the architecture of slimdump and are clearly out of the scope of this PR. So no objections and thanks a lot for your effort, @franziskahahn ! I'd be happy to see the merge as soon as possible. @mpdude I suggest to separate our concerns from the PR and do other improvements on demand. |
That's correct. _name is just one thing I would need and I can imagint that I am not alone with this issue. This is used as an example for the current way to extend the functionality.
I didn't think about it yet but I think it is a good idea. Maybe it is possible to add a new layer which makes extensions possible (maybe totally independent of faker). |
If we decide to merge this I could write documentation in a new PR or within this one (?).. |
@franziskahahn Talked to @mpdude earlier, he agreed to postpone the worries and asked me to thank you, too. It would be great if you could add the documentation in a separate PR, and after that I'd be glad to tag a new version. |
Yes - big thanks to you @franziskahahn for this addition! |
This PR adds faker integration to slimdump with two options:
Please comment before merging because I would like to add user documentation if everything else was discussed!
Of cause it is still possible to replace column value with static content: