public static function fromContents(string $contents): string
    {
        $class = "";
        $namespace = "";
        $tokens = token_get_all($contents);
        $len = count($tokens);

        for ($i = 0; $i < $len; $i++) {
            if ($tokens[$i][0] === T_NAMESPACE) {
                for ($j = $i + 1; $j < $len; $j++) {
                    if ($tokens[$j][0] === T_STRING) {
                        $namespace .= "\\".$tokens[$j][1];
                    }
                    else if ($tokens[$j] === "{" || $tokens[$j] === ";") {
                        break;
                    }
                }
            }
            else if ($tokens[$i][0] === T_CLASS) {
                for ($j = $i+1; $j < $len; $j++) {
                    if ($tokens[$j][0] === T_STRING) {
                        $class = $tokens[$j][1];
                        break 2;
                    }
                }
            }
        }

        if ($class === "") {
            return "";
        }
        return ($namespace === "")
            ? $class
            : trim($namespace."\\".$class, "\\");
    }