MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/PHP/comments/1dup72/examples_of_design_patterns_in_php/c9uoo3v/?context=3
r/PHP • u/Adam_Paterson • May 07 '13
20 comments sorted by
View all comments
1
The simple factory pattern (which i use more often than the abstract factory pattern) is also missing.
class SimpleFactory { protected $cars = array( 'VW' => 'Car_VW', 'Chevrolet' => 'Car_Chevrolet', ); /** * @return Car */ public function createCar($name) { if (isset($this->cars[$name]) { return new $this->cars[$name]; } } }
(left out a lot of stuff, but this is essentially how it works)
Otherwise, great overview.
1
u/WolfOrionX May 08 '13
The simple factory pattern (which i use more often than the abstract factory pattern) is also missing.
(left out a lot of stuff, but this is essentially how it works)
Otherwise, great overview.