Created
May 14, 2020 10:19
-
-
Save boghy933/6c8f1d3c7811f04d269f1ca022a50c66 to your computer and use it in GitHub Desktop.
Factory Pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class ProductCreator { | |
abstract public function factoryMethod(){} | |
} | |
class ConcreteCarPartCreator extends ProductCreator { | |
public function factoryMethod(){ | |
return new ConcreteCarPart; | |
} | |
} | |
class ConcreteCommercialTimeCreator extends ProductCreator { | |
public function factoryMethod(){ | |
return new ConcreteCommercialTime; | |
} | |
} | |
interface Product { | |
} | |
class ConcreteCarPart implements Product { | |
} | |
class ConcreteCommercialTime implements Product { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment