mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-09-25 22:09:23 +02:00
39 lines
707 B
PHP
39 lines
707 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Creational\Builder;
|
|
|
|
use DesignPatterns\Creational\Builder\Parts\Vehicle;
|
|
|
|
class BikeBuilder implements BuilderInterface
|
|
{
|
|
/**
|
|
* @var Parts\Bike
|
|
*/
|
|
private $bike;
|
|
|
|
public function addDoors()
|
|
{
|
|
}
|
|
|
|
public function addEngine()
|
|
{
|
|
$this->bike->setPart('engine', new Parts\Engine());
|
|
}
|
|
|
|
public function addWheel()
|
|
{
|
|
$this->bike->setPart('forwardWheel', new Parts\Wheel());
|
|
$this->bike->setPart('rearWheel', new Parts\Wheel());
|
|
}
|
|
|
|
public function createVehicle()
|
|
{
|
|
$this->bike = new Parts\Bike();
|
|
}
|
|
|
|
public function getVehicle(): Vehicle
|
|
{
|
|
return $this->bike;
|
|
}
|
|
}
|