İbrahim Gündüz
1 min readJul 8, 2019

--

to be honest, it’s hard to say something with just looking the file names. But at first sight, I can say you don’t really use the interface called MessengerInterface or just use as a marker interface. If they don’t share the same method signature, we can’t mention they are in the same class family.

If we return back my previous comment:
You can implement interface for those implementations:
Basically, you can put a method signature on the interface to be implemented by all providers.
You can create proxy classes:
You can create a proxy class for each implementation to decorate them and you can easly decorate by Symfony.This will help you to change method signature or the flow without touching the real implementation.
https://medium.com/@ibrahimgunduz34/decoration-of-services-with-symfony-813e35f1025e
https://symfony.com/doc/current/service_container/service_decoration.html
You can leave the implementation as it is and communicate the decision mechanism and implementation through an event mechanism:
Besides the subject, you can throw events from the handler class which will be handled by event listeners that talks directly with implementation. But I think there is no need to over-engineering like this :). The first solution is much more simple than others.

--

--

No responses yet