jpc/design-pattern 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jpc/design-pattern

最新稳定版本:1.1.0

Composer 安装命令:

composer require jpc/design-pattern

包简介

Simple Design Patter integration

README 文档

README

DesignPattern library allow you to simply include design pattern like Singleton or Multiton into your classes.

Installation

Use composer require jpc/design-pattern to install with composer.

How to use

Create the singleton class

Create your class which you want to be a Singleton class.

<?php
	class MySingletonClass {
    	// Some properties and functions
        
        public function __construct($myFristParam, $mySecondParam){
        	//...
        }
    }
?>

Then, add the Singleton trait.

<?php
	class MySingletonClass {
    
    	use JPC\DesignPattern\Singleton;
    
    	// Some properties and functions
        
        public function __construct($myFristParam, $mySecondParam){
        	//...
        }
    }
?>

Get the Singleton class

You can simply use the static function getInstance to get singleton instance.

//Some Code
$mySingleton = MySingletonClass::getInstance($param1, $param2);
//Some Code

For Multiton

The unique difference between Singleton and Multiton is when you get the instance, you have to pass an identifier like that :

//Some Code
$myMultiton = MyMultitonClass::getInstance("IDENTIFIER", $param1, $param2);
//Some Code

It's allow you to make different instance with different parameters.

Thanks You!

Thanks you for reading and maybe for downloading and use this library! If you have some request, make them and i will code it for you!

统计信息

  • 总下载量: 42.49k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2016-09-29