Skip to content

object42/enum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

enum

adds helper functions for enums

installation

composer require object42/enum

usage

first add the helper-trait to your enum:


<?php

declare(strict_types=1);

namespace App\Enums;

use object42\Enum\EnumHelper;

enum MyEnum:int
{
    use EnumHelper;

    case ONE = 1;
    case TWO = 2;
}

names()

MyEnum::names(); // ['ONE', 'TWO']

values()

MyEnum::values(); // [1, 2]

Note: pure enum (non-backed) will return the names (since they don't have values)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages