Skip to content

Instantly share code, notes, and snippets.

@boghy933
Created May 14, 2020 10:19
Show Gist options
  • Save boghy933/6c8f1d3c7811f04d269f1ca022a50c66 to your computer and use it in GitHub Desktop.
Save boghy933/6c8f1d3c7811f04d269f1ca022a50c66 to your computer and use it in GitHub Desktop.
Factory Pattern
<?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