adds helper functions for enums
composer require object42/enum
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;
}
MyEnum::names(); // ['ONE', 'TWO']
MyEnum::values(); // [1, 2]
Note: pure enum (non-backed) will return the names (since they don't have values)