共生体/支持启动特性

启动特性支持

v1.0 2024-06-27 10:01 UTC

This package is auto-updated.

Last update: 2024-09-27 08:27:56 UTC


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!'

文档

此文档仅对包的技术使用进行说明,文本很少。

测试

composer test

许可证

MIT 许可证