| 1 |
<?php |
| 2 |
|
| 3 |
namespace ElementorOne\Common; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; // Exit if accessed directly. |
| 7 |
} |
| 8 |
|
| 9 |
/* |
| 10 |
* BasicEnum class |
| 11 |
*/ |
| 12 |
abstract class BasicEnum { |
| 13 |
|
| 14 |
/** |
| 15 |
* Entries |
| 16 |
* @var array |
| 17 |
*/ |
| 18 |
private static array $entries = []; |
| 19 |
|
| 20 |
/** |
| 21 |
* @throws \ReflectionException |
| 22 |
*/ |
| 23 |
public static function get_values(): array { |
| 24 |
return array_values( self::get_entries() ); |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* @throws \ReflectionException |
| 29 |
*/ |
| 30 |
protected static function get_entries(): array { |
| 31 |
$caller = get_called_class(); |
| 32 |
|
| 33 |
if ( ! array_key_exists( $caller, self::$entries ) ) { |
| 34 |
$reflect = new \ReflectionClass( $caller ); |
| 35 |
self::$entries[ $caller ] = $reflect->getConstants(); |
| 36 |
} |
| 37 |
|
| 38 |
return self::$entries[ $caller ]; |
| 39 |
} |
| 40 |
} |
| 41 |
|