I have the below sample code:
<?php
enum Suit: string
{
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
}
$enumClass = '\Suit';
$hearts = $enumClass::from('H');
var_dump($hearts);
it produces output
enum(Suit::Hearts)
which is desired. However, is there a way to do this using some function calls and not dynamic $enumClass::from('H'); ? Such as get_enum($enumClass)::from('H') or like that?
get_enum($enumClass)would be useful in some other way?