public static function classToName($class, $type)
    {
        if (!class_exists($class)) {
            throw new InvalidArgumentException(
                "Class '" . $class . "' not found!"
            );
        }
        $class = self::_trimNamespace($class);

        if (!isset(self::$masks[$type])) {
            throw new InvalidArgumentException(
                "Invalid mask type " . $type . "!"
            );
        }

        $mask = self::_trimNamespace(self::$masks[$type]);

        if ($mask === "*") {
            return $class;
        }

        preg_match("/" . str_replace("*", "(.*)", $mask) . "/", $class, $match);
        return $match[1];
    }