-
Notifications
You must be signed in to change notification settings - Fork 20
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
In string method notation #154
Comments
Please vote as follows: Authors::active::verified 😄
Authors#active#verified 👍
Authors->active->verified ❤️
Authors@active@verified 👎 |
If what you propose is feasible (mapping Authors:: and Address:: to the correct factory), wouldn't the following have the best of both worlds. To get Full autocompletion, we would have to set the return type for Authors() and Address(), but maybe worth the additional effort
The ucfirst letter would be the convention for a factory method in the chain. There would be a magic getter only on ucfirst method calls. |
I personally was never really a fan of "compressing" chained function calls into a string separated by |
I don't think I would use it either as a string BTW |
This is a great idea @pakacuda. We ideally want a way to do something like this too: ArticleFactory::make()
->with('Authors#published#active[10].Address#verified')
->with('Authors#published#inactive[10].Address#notVerified')
->getEntity(); Need to think about how to with the magic getter solution, but I agree that this beats the not-handy string notation solution. |
ArticleFactory::make()
->Authors(10)->published()->active()->Address()->verified()
->andAuthors(10)->published()->inactive()->Address()->notVerified()
->getEntity() would actually work if we introduce a root factory property. The magic getter will know that the prefix What do you all think of this syntax? |
Often little setters are added to a given factory. E.g.:
These setters could be specified in the in string notation of the
with
method:Pros:
Cons:
If the method is not found, possibly due to some refactoring, an exception will be raised specifiying that the provided method does not exist.
Question 1:
Do you agree on the utility of the feature?
Question 2:
If yes, what is your prefered notation?
#
or:
or::
or->
or something else?The text was updated successfully, but these errors were encountered: