Created
March 22, 2017 16:55
-
-
Save event15/9c25b49894515ae36752eaad28ec2f91 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
class CarBuilder implements BuilderInterface | |
{ | |
/** | |
* @var Parts\Car | |
*/ | |
private $car; | |
public function addDoors() | |
{ | |
$this->car->setPart('rightDoor', new Parts\Door()); | |
$this->car->setPart('leftDoor', new Parts\Door()); | |
$this->car->setPart('trunkLid', new Parts\Door()); | |
} | |
public function addEngine() | |
{ | |
$this->car->setPart('engine', new Parts\Engine()); | |
} | |
public function addWheel() | |
{ | |
$this->car->setPart('wheelLF', new Parts\Wheel()); | |
$this->car->setPart('wheelRF', new Parts\Wheel()); | |
$this->car->setPart('wheelLR', new Parts\Wheel()); | |
$this->car->setPart('wheelRR', new Parts\Wheel()); | |
} | |
public function createVehicle() | |
{ | |
$this->car = new Parts\Car(); | |
} | |
public function getVehicle(): Vehicle | |
{ | |
return $this->car; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment