共生体 / 支持启动特性
启动特性支持
v1.0
2024-06-27 10:01 UTC
Requires
- php: ^8.2
Requires (Dev)
- mockery/mockery: ^1.6
- phpunit/phpunit: ^11.1
README
使用 initializeTraitName()
的 Laravel 的 boot/initialize 特性的紧凑版本。
此包正在开发中!
要求
php 8.2
安装
composer require symbiont/support-boot-trait
使用
使用 BootsTrait
的简单示例。
use Symbiont\Support\BootTrait\Contracts\BootsTraits;
use Symbiont\Support\BootTrait\BootsTrait;
trait SomeTrait {
protected string $property;
protected function initializeSomeTrait(bool $option) {
$this->property = if($option) ?
'whoohoo!' : 'booya!';
}
public function getProperty() {
}
}
class AwesomeClass implements BootsTraits {
use SomeTrait,
BootsTrait;
public function __construct(string $something, bool $option) {
$this->bootTraits([
SomeTrait::class => [$option]
]);
}
}
(new Awesome('test', true))->getProperty();
// will output 'whoohoo!'
文档
此文档仅对包的技术使用进行说明,文本很少。
- 文档:https://symbiont.gitlab.io/support/boot-trait
- Gitlab:https://gitlab.com/symbiont/support/boot-trait
测试
composer test