Commit 5a86003f authored by Jan Kuchař's avatar Jan Kuchař

InstanceRegister: more comments removed unused code

parent 9847c914
......@@ -2,22 +2,25 @@
namespace Grifart\Enum\Internal;
/**
* Keeps track of all enum instances organized by enum root classes.
*/
final class InstanceRegister
{
/** @var \Grifart\Enum\Internal\Meta[] */
private static $instances = [];
public static function get(string $enumClass, callable $registrator = null): Meta
public static function get(string $enumClass, callable $registrar): Meta
{
if (!isset(self::$instances[$enumClass]) && $registrator !== null) {
self::register($registrator());
if (!isset(self::$instances[$enumClass])) {
self::register($registrar());
}
return self::$instances[$enumClass];
}
public static function register(Meta $meta): void
{
// check consistency of enum when assertions are enabled
// check consistency of enum when assertions are enabled (typically non-production code)
assert(
(function () use ($meta): bool {
ConsistencyChecker::checkAnnotations($meta);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment