41 lines
979 B
PHP
41 lines
979 B
PHP
<?php
|
|
|
|
/**
|
|
* @package: patterns
|
|
* @author: Yevhen Odynets
|
|
* @date: 2025-07-04
|
|
* @time: 08:13
|
|
*/
|
|
|
|
declare(strict_types = 1);
|
|
|
|
use Pattern\Creational\Prototype\Author;
|
|
use Pattern\Creational\Prototype\Page;
|
|
|
|
function client(): void
|
|
{
|
|
$author = new Author("Джордж Орвелл");
|
|
$page = new Page(
|
|
"Колгосп тварин",
|
|
"Притча, сповнена гіркої іронії і сарказму.
|
|
Трагікомічна історія спільноти тварин, що зважилися позбутися пригноблення людьми,
|
|
і потрапила під бузувірську владу свиней.",
|
|
$author
|
|
);
|
|
|
|
// ...
|
|
|
|
$page->addComment("Nice book!");
|
|
|
|
// ...
|
|
|
|
$draft = clone $page;
|
|
|
|
echo "Dump of the clone. Note that the author is now referencing two objects.\n\n";
|
|
|
|
/** @noinspection ForgottenDebugOutputInspection */
|
|
dump($draft);
|
|
}
|
|
|
|
client();
|