Skip to content

Instantly share code, notes, and snippets.

@event15
Created March 22, 2017 16:55
Show Gist options
  • Save event15/9c25b49894515ae36752eaad28ec2f91 to your computer and use it in GitHub Desktop.
Save event15/9c25b49894515ae36752eaad28ec2f91 to your computer and use it in GitHub Desktop.
<?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