evolutionphp/instance
最新稳定版本:v1.0
Composer 安装命令:
composer require evolutionphp/instance
包简介
Convert PHP classes to static
关键字:
README 文档
README
Simple class to convert PHP classes to static and reusable
Example
Test Class:
class Test{ private $name = ''; public function ___construct($name='') { $this->name = $name; } public function setName($name) { $this->name = $name; return $this; } public function getName() { return $this->name; } }
Convert to static class:
$static = \EvolutionPHP\Instance\Instance::get(Test::class); $static->setName('Smith'); echo $static->getName(); //Returns Smith echo \EvolutionPHP\Instance\Instance::get(Test::class)->getName(); //Returns Smith
Register arguments or recycle instance:
$static = \EvolutionPHP\Instance\Instance::register(Test::class, ['John']); //It is like: new Test('John'); echo $static->getName(); //Returns John echo \EvolutionPHP\Instance\Instance::get(Test::class)->getName(); //Returns John echo \EvolutionPHP\Instance\Instance::register(Test::class, ['Smith'])->getName(); //Returns Smith
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-12