Skip to content

Latest commit

 

History

History
34 lines (24 loc) · 723 Bytes

constructor.md

File metadata and controls

34 lines (24 loc) · 723 Bytes

Constructor

For people coming from Spatie's PHP Enum, this one will allow you to easily migrate away to actual enums.

Usage

Add the Constructor trait and add the docblock just like you would with Spatie's package.

use Henzeb\Enumhancer\Concerns\Constructor;

/**
 * @method static self CALLABLE()
 */
enum yourEnum {
    use Constructor;
    
    case CALLABLE;
    
}

Examples

YourEnum::CALLABLE(); // will return YourEnum::CALLABLE;

Note: Under the hood it is using __callStatic, so it may give some unpredicted behavior when calling a method that doesn't exist.

Note: This trait is not enabled by default when using the Enumhancer trait.