Open pabloelcolombiano opened 2 years ago
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
ArticleFactory::make()->Authors(10)->published()->active()->Address()->verified()->getEntity()
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. Otherwise, I would vote for 👍 just because two colon in a row might be error prone
I personally was never really a fan of "compressing" chained function calls into a string separated by <something>
.
Therefore this is my vote for "I don't mind/care" because it wouldn't be usefull to me 😄
I don't think I would use it either as a string BTW
ArticleFactory::make()->Authors(10)->published()->active()->Address()->verified()->getEntity()
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 and
refers to an association of the root factory property.
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?