Comments & Discussion
F
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
public function getSalaryAttribute(SalaryCalculatorInterface $salarayCalculator) { //And then for any type of position, we'll juste have to do $salarayCalculator->calculate($this->start_date) }
What do you think ?
P
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?