$this->value, $this instanceof UnitEnum => $this->name, default => throw new ConstantsException('This trait must in enum'), }; return static::getValue($name, [$code, ...$arguments]); } /** * @throws ConstantsException * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public static function __callStatic(string $name, array $arguments): array|string { if (! is_subclass_of(static::class, UnitEnum::class)) { throw new ConstantsException('This trait must in enum'); } if (! empty($arguments)) { if ($arguments[0] instanceof BackedEnum) { $arguments[0] = $arguments[0]->value; } elseif ($arguments[0] instanceof UnitEnum) { $arguments[0] = $arguments[0]->name; } } return static::getValue($name, $arguments); } }