I had a situation where a route call a method to get an amount, and this method used a switch for check the type (Each case call a method).
I'm using Laravel with the pattern of repository/interface so I created 2 repositories (I notice that some cases of the switch are similars so I decided to integrate them in the repositories).
Hi Sandi, thanks for doing this AMA!
I had a situation where a route call a method to get an amount, and this method used a switch for check the type (Each case call a method).
I'm using Laravel with the pattern of repository/interface so I created 2 repositories (I notice that some cases of the switch are similars so I decided to integrate them in the repositories).
First I create an array of the repositories
Then in the method amount I change to this
What do you think? (I take base of this article of you when-code-duplication-is-the-right...