mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 17:52:25 +01:00
46 lines
871 B
PHP
46 lines
871 B
PHP
<?php
|
|
|
|
/*
|
|
* DesignPatternPHP
|
|
*/
|
|
|
|
namespace DesignPatterns\Builder;
|
|
|
|
/**
|
|
* CarBuilder builds car
|
|
*/
|
|
class CarBuilder implements Builder
|
|
{
|
|
|
|
protected $car;
|
|
|
|
public function addDoors()
|
|
{
|
|
$this->car->setPart('rightdoor', new Parts\Door());
|
|
$this->car->setPart('leftDoor', 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()
|
|
{
|
|
return $this->car;
|
|
}
|
|
|
|
} |