Skip to content

Commit b94900e

Browse files
refactor: Optimize isValid() method using tryFrom()
1 parent 6d9a986 commit b94900e

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

Enums/WalletEnums.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ enum WalletEnums: string
1212
*/
1313
public static function isValid(string $type): bool
1414
{
15-
foreach (self::cases() as $case) {
16-
if ($case->value === $type) {
17-
return true;
18-
}
19-
}
20-
21-
return false;
15+
return self::tryFrom($type) !== null;
2216
}
2317
}

0 commit comments

Comments
 (0)