It's getting a bit tricky. You have created App/Calculators folder with calculator files/classes in it.
How you would call them - is it Actions, is it Helpers?
What are those classes?
Instead of having an associative array matching the position and the corresponding class, can we not use the interface? I think we'll have somthing like this
publicfunctiongetSalaryAttribute(SalaryCalculatorInterface $salarayCalculator) {//And then for any type of position, we'll juste have to do $salarayCalculator->calculate($this->start_date)}
I really don't like this example. If you want to check the consistency of your salary policy, you have to open a file for each employee type and layout them in such a way that you have an overview. Having all in one file violates the open-closed principle but is much faster to read, check, compare, ....
It's getting a bit tricky. You have created App/Calculators folder with calculator files/classes in it. How you would call them - is it Actions, is it Helpers? What are those classes?
Instead of having an associative array matching the position and the corresponding class, can we not use the interface? I think we'll have somthing like this
What do you think ?
Hmm, I think it's quite a good idea, can't answer 100% without trying it out but I think that would work.
Alright Povilas Korop.Thanks
I really don't like this example. If you want to check the consistency of your salary policy, you have to open a file for each employee type and layout them in such a way that you have an overview. Having all in one file violates the open-closed principle but is much faster to read, check, compare, ....