ervin-meng/php-design-patterns

PHP设计模式

Maintainers

Package info

github.com/ervin-meng/PHPDesignPatterns

Type:application

pkg:composer/ervin-meng/php-design-patterns

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

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

This package is auto-updated.

Last update: 2026-03-01 00:32:41 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);