Demystifying polymorphism – interfaces and abstract classes
As far as the separation of responsibilities is concerned, event dispatching is a concept that is already advanced. You can consider that your level in the world of clean code has increased considerably if you know this mechanism, understand it, and have the chance to use it. All this obviously requires a bit of setup. Either you implement this system by yourself or you use an external library. In the second case, there is obviously a whole learning phase to be included. Either way, this is obviously not the only way to improve the separation of your responsibilities. There is a way that is native to PHP to improve this separation, sometimes not used enough, sometimes misunderstood, and often underestimated. We are talking here about polymorphism, or vulgarly: abstract classes and interfaces.