diff --git a/app/Traits/Enums/BaseEnum.php b/app/Traits/Enums/BaseEnum.php index 573b085..033c03f 100644 --- a/app/Traits/Enums/BaseEnum.php +++ b/app/Traits/Enums/BaseEnum.php @@ -250,19 +250,20 @@ trait BaseEnum $names = array_merge($names, [$enum->name => $enum]); }, self::cases()); - $GLOBALS[self::class]['customProps'] = \array_map( - function (mixed $enum) use ($names) { - if (!\is_array($enum)) { + $GLOBALS[self::class]['customProps'] = \array_filter( + (new \ReflectionClass(self::class))->getConstants(), + function (mixed $constant, string $key) use ($names) { + if ($key === 'LABELS' or !\is_array($constant)) { return false; } return count(\array_filter( - $enum, + array_flip($constant), function (string $name) use ($names) { return array_key_exists($name, $names); } )); }, - array_flip((new \ReflectionClass(self::class))->getConstants()), + ARRAY_FILTER_USE_BOTH ); } //end if return $GLOBALS[self::class]['customProps'];