lundi 23 novembre 2020

make a factory of factory

I have two factory:

class Factory
{
   public static function getInstance($type) {
     .....
   }
}

and

class Factory
{
   public static function getInstance($type) {
     .....
   }

}

so, now I want to make an factory of my two factory like this :

class FactoryOfFactory
{
  public static function getFactory($service)
  {
    switch ($service) {
      case 'fac1':
        $Factory = new Factory();
        break;
      case 'fac2':
        $Factory = new Factory();
    }

    return $Factory
  }
}

so I don't know to differentiate my two factory

thank for help

Aucun commentaire:

Enregistrer un commentaire