Skip to content

Commit

Permalink
Allow other enum types to be remade if value is the same
Browse files Browse the repository at this point in the history
  • Loading branch information
juniwalk authored Dec 20, 2024
1 parent 469178a commit c04f366
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Enums/Traits/Labeled.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace JuniWalk\Utils\Enums\Traits;

use BackedEnum;
use JuniWalk\Utils\Enums\Color;
use JuniWalk\Utils\Enums\Interfaces\LabeledEnum; // ! Used for @phpstan
use JuniWalk\Utils\Html;
Expand Down Expand Up @@ -59,6 +60,10 @@ public static function make(mixed $value, bool $required = true): ?static
return $value;
}

if ($value instanceof BackedEnum) {
$value = $value->value;
}

if ($value instanceof Stringable || is_string($value) || is_int($value)) {
$value = (string) $value;

Expand Down

0 comments on commit c04f366

Please sign in to comment.