I have a factory class that decides to which bank service should instantiated based on input so I created it with switch in factory class like this:
class BankFactory
{
public static function build($iban)
{
switch ($iban){
case "123":
return new BankXService();
case "456":
return new BankYService();
}
}
}
But every time that I want to add a bank service switch case is longer and longer.
Is there any better design pattern for this task?
Aucun commentaire:
Enregistrer un commentaire