aviator/makeable
最新稳定版本:0.1.0
Composer 安装命令:
composer require aviator/makeable
包简介
Static constructor trait and interface.
关键字:
README 文档
README
Overview
This package provides a static constructor interface, and a trait that implements the interface.
Installation
Via Composer:
composer require aviator/makeable
Testing
Via Composer:
composer test
Usage
Use the trait:
class Something { use MakeableTrait; }
Then the class can be instantiated using Class::make(...$args):
$instance = Something::make($arg1, $arg2);
The interface is optional, though it can be useful in composite interfaces to specify that a static constructor should be present:
interface SomeInterface extends Makeable, SomeOtherInterface { /* ... etc */ }
Since the static constructor simply returns new static(...$args), it can be used in abstract classes and parent classes without having to re-use it on child classes:
abstract class Seuss { use MakeableTrait; } class ThingOne extends Seuss {}; class ThingTwo extends ThingOne {}; // Get an instance of ThingOne $instance = ThingOne::make(); // Get an instance of ThingTwo $instance = ThingTwo::make();
Other
License
This package is licensed with the MIT License (MIT).
统计信息
- 总下载量: 2.88k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-11-30