mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 01:32:22 +01:00
25 lines
601 B
PHP
25 lines
601 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Creational\Builder;
|
|
|
|
use DesignPatterns\Creational\Builder\Parts\Vehicle;
|
|
|
|
/**
|
|
* Director is part of the builder pattern. It knows the interface of the builder
|
|
* and builds a complex object with the help of the builder
|
|
*
|
|
* You can also inject many builders instead of one to build more complex objects
|
|
*/
|
|
class Director
|
|
{
|
|
public function build(BuilderInterface $builder): Vehicle
|
|
{
|
|
$builder->createVehicle();
|
|
$builder->addDoors();
|
|
$builder->addEngine();
|
|
$builder->addWheel();
|
|
|
|
return $builder->getVehicle();
|
|
}
|
|
}
|