实例化特质
github.com/galancev/instance
源代码
问题
安装数量: 1,161
依赖项: 1
建议者: 0
安全: 0
星标: 1
关注者: 2
分支: 0
公开问题: 0
Requires
Requires (Dev)
None
Suggests
Provides
Conflicts
Replaces
GPL-3.0-only 66039c60255ff8ac8bb4568de5c2cf08ad265007
This package is auto-updated.
Last update: 2024-09-29 06:08:31 UTC
用于轻松实例化类的特质。
只需在任何类中添加此特质即可
class Test { use Instance; }
即可使用魔法方法
创建类的新实例
Test::factory()
创建类的单例
Test::instance()
使用示例
class StringHelper { use Instance; public function reverse($string) { return strrev($string); } } echo StringHelper::instance()->reverse('1234567890');