Design Patterns in OOP PHP - Factory Method
Design Patterns in OOP PHP course - Factory Method factory method Most popular pattern you Define interface for creating object but let the subclasses decide which class to initiate factory method lets a class defers instantiation to subclasses Example we want to have two cars brand each one implements the same interface and two other classes that implements factory interface those class are responsible for creating object from we will create as following interface car brand have one method two brand classes bmwBrand and benzBrand implements car brand one interface brand factory two classes implements the brand factory and will be responsible for creating new object from the two brand classes bmwBrand and benzBrand carBrandInterface <?php namespace Creational\FactoryMethod ; interface CarBrandInterface { public function createBrand (); } ? > BenzBrand class <?php namespace Creational\FactoryMethod ; class BenzBran...