public static function getEnumById($enumId, $ignoreNotFound = false)
    {
        if ($enumId instanceof EnumId) {
            $enumId = $enumId->toString();
        }

        if (isset(self::$enums[$enumId])) {
            return self::$enums[$enumId];
        }

        if (!$ignoreNotFound) {
            throw new \RuntimeException(sprintf('Enum with id "%s" is invalid.', $enumId));
        }

        return null;
    }