made some refactoring

This commit is contained in:
2025-07-09 05:28:39 +03:00
parent f76eb08fe0
commit 38676bc9fd
69 changed files with 3075 additions and 355 deletions

View File

@@ -0,0 +1,43 @@
<?php
/**
* @package: patterns
* @author: Yevhen Odynets
* @date: 2025-07-04
* @time: 00:19
*/
declare(strict_types = 1);
use Pattern\Creational\Builder\BigMacBuilder;
use Pattern\Creational\Builder\Director;
/**
* The client code creates a builder object, passes it to the director and then
* initiates the construction process. The end result is retrieved from the
* builder object.
*
* @noinspection ForgottenDebugOutputInspection*/
function clientCode(Director $director): void
{
$builder = new BigMacBuilder();
$director->setBuilder($builder);
echo 'Preparing full featured Big Mac...';
$director->regularBigMac();
dump($builder->getBigMac()->getIngredients());
echo 'Preparing vegan Big Mac...';
$director->veganBigMac();
dump($builder->getBigMac()->getIngredients());
// The Builder pattern can be used without a Director class.
echo 'Preparing a custom snack...';
$builder->produceBun();
$builder->produceMeat();
$builder->produceSauce();
dump($builder->getBigMac()->getIngredients());
}
clientCode(new Director());