Skip to content

Instantly share code, notes, and snippets.

@artemrogov
Last active May 10, 2016 19:34
Show Gist options
  • Save artemrogov/ceebd5b9cf016145f858a8c34d23e3ee to your computer and use it in GitHub Desktop.
Save artemrogov/ceebd5b9cf016145f858a8c34d23e3ee to your computer and use it in GitHub Desktop.
Паттерны проектирования Фабрика
/* фабрика */
class Auto {
private $_make;
private $_model;
public function __construct($make, $model){
$this->_make = $make;
$this->_model = $model;
}
public function getMakeModel(){
return $this->_make . ' '.$this->_model;
}
}
class AutoFactory {
public static function create($make, $model){
return new Auto($make,$model);
}
}
$objAuto = AutoFactory::create('BMW','X5');
echo $objAuto->getMakeModel();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment