Last active
May 10, 2016 19:34
-
-
Save artemrogov/ceebd5b9cf016145f858a8c34d23e3ee to your computer and use it in GitHub Desktop.
Паттерны проектирования Фабрика
This file contains hidden or 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
/* фабрика */ | |
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