feat(trait): menambahkan WithCommentEnum dan WithValueEnum

This commit is contained in:
Yoga Pangestu 2025-09-24 19:26:10 +07:00
parent 6317037796
commit 8211f819b0
2 changed files with 22 additions and 0 deletions

View File

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