Files
DesignPatternsPHP/Creational/Builder/TruckBuilder.php
2019-08-19 18:11:49 +02:00

45 lines
1.1 KiB
PHP

<?php declare(strict_types=1);
namespace DesignPatterns\Creational\Builder;
use DesignPatterns\Creational\Builder\Parts\Vehicle;
class TruckBuilder implements Builder
{
/**
* @var Parts\Truck
*/
private $truck;
public function addDoors()
{
$this->truck->setPart('rightDoor', new Parts\Door());
$this->truck->setPart('leftDoor', new Parts\Door());
}
public function addEngine()
{
$this->truck->setPart('truckEngine', new Parts\Engine());
}
public function addWheel()
{
$this->truck->setPart('wheel1', new Parts\Wheel());
$this->truck->setPart('wheel2', new Parts\Wheel());
$this->truck->setPart('wheel3', new Parts\Wheel());
$this->truck->setPart('wheel4', new Parts\Wheel());
$this->truck->setPart('wheel5', new Parts\Wheel());
$this->truck->setPart('wheel6', new Parts\Wheel());
}
public function createVehicle()
{
$this->truck = new Parts\Truck();
}
public function getVehicle(): Vehicle
{
return $this->truck;
}
}