Skip to content

Jasonej/bootable-traits

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bootable Traits

A simple package for enabling the booting of traits.

Installation

composer require jasonej/bootable-traits

Usage

<?php

use Jasonej\BootableTraits\BootsTraits;

trait ExampleTrait
{
    public $booted = false;

    public function bootExampleTrait(): void
    {
        $this->booted = true;
    }
}

class ExampleClass
{
    use BootsTraits;
    use ExampleTrait;

    public function __construct()
    {
        static::bootTraits($this);
    }
}
<?php

use Jasonej\BootableTraits\BootsTraits;

trait ExampleTrait
{
    public static $booted = false;

    public static function bootExampleTrait(): void
    {
        static::$booted = true;
    }
}

class ExampleClass
{
    use BootsTraits;
    use ExampleTrait;

    public static function init()
    {
        static::bootTraits();
    }
}

About

Quickly and easily enable booting of traits in any class.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages