feat(trait): add WithComment and Withvalue for enum utils

This commit is contained in:
Yoga Pangestu 2025-10-24 08:29:22 +07:00
parent bcc442a00b
commit c9e012e387
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,11 @@
<?php
namespace App\Traits\Enum;
trait WithComment
{
public static function comment(): string
{
return implode(', ', array_map(fn ($case) => "{$case->value}: {$case->label()}", self::cases()));
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Traits\Enum;
trait WithValue
{
public static function values(): array
{
return array_map(fn ($case) => $case->value, self::cases());
}
}