vendredi 3 août 2018

Handling multiple Interfaces within a __construct

I have multiple interfaces that I call within a class construct, however pulling in 3 or more Interfaces within a parent constructor seems to be a bit much. Is there a better way to do something like this?

   private $one;
   private $two;
   private $three;

   public function __construct(OneInterface $one, TwoInterface $two, ThreeInterface $three) {
      $this->one = $one;
      $this->two = $two;
      $this->three = $three;
   }

I find this approach to applicable when only 1 interface is to be required but 3 or more just doesn't feel right. Is there a solution to dealing with something like this? eg, one interface that implements all interfaces?

Aucun commentaire:

Enregistrer un commentaire