ervin-meng/php-design-patterns

PHP设计模式

dev-master 2020-09-01 09:12 UTC

This package is auto-updated.

Last update: 2025-06-29 01:50:18 UTC


README

代码示例

<?php

use PHPDesignPatterns\Creational\Builder\Builder;
use PHPDesignPatterns\Creational\Builder\Director;
use PHPDesignPatterns\Creational\Singleton\Singleton;
use PHPDesignPatterns\Creational\Prototype\Prototype;

//原型模式
$prototype = new Prototype();
$prototype->setStatus(1);
$prototypeOne = clone $prototype;
echo $prototypeOne->getStatus();
//单例模式
$instance = Singleton::getInstance();
//创建者模式
$director = new Director();
$builder  = new Builder();
$director->build($builder);