symbiont/support-boot-trait

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

This package is auto-updated.

Last update: 2024-08-27 08:24:15 UTC


README

Compact version of Laravel's boot/initialize traits using initializeTraitName().

This package is work in progress!

Requirements

  • php 8.2

Installation

composer require symbiont/support-boot-trait

Usage

Simple example of using 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!'

Documentation

This documentation only documents the technical usage of this package with little to no text.

Tests

composer test

License

MIT license