@param string $path
@param int $line

@return string
493472
public static function getIdeLink(string $path, int $line = null) : ?string
    {
        $fileLinkFormat = ini_get('xdebug.file_link_format') ?: 'phpstorm://%f:%l';

        if ($path != '[internal function]' && $path != '{main}') {
            $path = self::mapPath($path);

            return str_replace(
                ['%f', '%l'],
                [$path, $line ?? 1],
                $fileLinkFormat
            );
        }

        return null;
    }
663648
private function parseLine($line)
    {
        if ($line == '') {
            return;
        }

        $slices = NodeObject::getLineSlices($line);
        if ($this->isBlob()) {
            $this->pathChildren[] = $this->blob->getName();
        } else {
            if ($this->isRoot()) {
                // if is root check for first children
                $pattern = '/(\w+)\/(.*)/';
                $replacement = '$1';
            } else {
                // filter by the children of the path
                $actualPath = $this->subject->getFullPath();
                if (!preg_match(sprintf('/^%s\/(\w*)/', preg_quote($actualPath, '/')), $slices['fullPath'])) {
                    return;
                }
                $pattern = sprintf('/^%s\/(\w*)/', preg_quote($actualPath, '/'));
                $replacement = '$1';
            }

            $name = preg_replace($pattern, $replacement, $slices['fullPath']);
            if (strpos($name, '/') !== false) {
                return;
            }

            if (!in_array($name, $this->pathChildren)) {
                $path = rtrim(rtrim($slices['fullPath'], $name), '/');
                $treeObject = new TreeObject(
                    $this->repository,
                    $slices['permissions'],
                    $slices['type'],
                    $slices['sha'],
                    $slices['size'],
                    $name,
                    $path
                );
                $this->children[] = $treeObject;
                $this->pathChildren[] = $name;
            }
        }
    }
1104409
public static function loadDotFile($path)
    {
        $file = file_get_contents($path);
        if ($file === false) {
            return null;
        }

        $file = str_replace("\r", "\n", $file);      // Turn CR into LF
        $file = str_replace("\n\n", "\n", $file);   // Turn LFLF into LF
        $lines = explode("\n", $file);

        $data = [];

        $lineCount = count($lines);

        for ($i = 0; $i < $lineCount; $i++) {
            $line = trim($lines[$i]);
            if (strlen($line) === 0) {
                continue;
            }

            $split = explode('=', $line, 2);
            if (count($split) < 2) {
                throw new Exception\ConfigurationException("Invalid data in .bitrank file on line $i. ($line)");
            }

            $key = $split[0];
            $value = $split[1];

            $data[$key] = $value;
        }

        return $data;
    }
423069
public static function getCssInlineTags(string $path): string
    {
        $result = self::getFile($path);
        if ($result) {
            $result = "<style>\r\n".$result."</style>\r\n";

            return $result;
        }

        return '';
    }
1359537
public static function getPath(string $path): string {
		$e = explode("/", $path);
		unset($e[count($e) - 1]);

		return implode("/", $e);
	}
1259273
public function parse($line)
    {
        $object = new \stdClass();

        $object->type = 'info';
        $object->message = $line;

        return $object;
    }
697054
public function includeInlineCssTags(string $path): \Twig\Markup
    {
        return Template::raw(
            Twigpack::$plugin->manifest->getCssInlineTags($path)
        );
    }
674347
protected function getCode($path, $line, $numLines)
    {
        if (empty($path) || empty($line) || !file_exists($path)) {
            return;
        }

        try {
            $file = new SplFileObject($path);
            $file->seek(PHP_INT_MAX);

            $bounds = static::getBounds($line, $numLines, $file->key() + 1);

            $code = [];

            $file->seek($bounds[0] - 1);
            while ($file->key() < $bounds[1]) {
                $code[$file->key() + 1] = rtrim(substr($file->current(), 0, static::MAX_LENGTH));
                $file->next();
            }

            return $code;
        } catch (RuntimeException $ex) {
            // do nothing
        }
    }
1298435
private function getFirstSegmentOfKey(Line $line)
    {
        // Remove first part since that part equals the page
        $key = substr($line->key, strpos($line->key, '.')+1);

        $length = strpos($key, '.')?: strlen($key);
        $key = substr($key, 0, $length);

        return $key;
    }
67478
public static function getCode($file, $line) {
		if (empty($file)) {
			return '';
		}
		$rows = explode("\n", file_get_contents($file));
		$start = ($line - 6) > 0 ? ($line - 6) : 0;
		$end = ($line + 5) < count($rows) ? ($line + 5) : count($rows);
		$result = [];
		for ($i = $start; $i < $end; $i++) {
			if ($i == $line - 1) {
				$result[] = '<b>' . $rows[$i] . '</b>';
			} else {
				$result[] = $rows[$i];
			}
		}
		return implode("\n", $result);
	}
232864
private function parseDescription( $line ) {
		while ( preg_match('/{@([^}]*)}/', $line, $matches) ) {
			switch( $matches[1] ) {
				case 'internal' : 
					$line = str_replace( $matches[0], '', $line );
				break;
				default :
					$line = str_replace( $matches[0], $matches[1], $line );
				break;
			}
		}
		$line = str_replace( array( '\@', '{@*}' ), array( '@', '*/' ), $line );
		return $line;
	}
1254385
public static function stripExt($path): string
    {
        $reg = '/\.' . preg_quote(self::ext($path), null) . '$/';
        $path = preg_replace($reg, '', $path);

        return $path;
    }
26871
private function formatPath(string $path): string
    {
        $path = $this->formatDataPath($path);

        static $pattern = '/(?:[^'.self::REGEXP_CHARS_UNRESERVED.self::REGEXP_CHARS_SUBDELIM.'%:@\/}{]++\|%(?![A-Fa-f0-9]{2}))/';

        $path = (string) preg_replace_callback($pattern, [Uri::class, 'urlEncodeMatch'], $path);

        return $this->formatFilePath($path);
    }
20135
private function translate($path)
    {
        $value = $this->translator->translate($path, $this->environment->getDataDefinition()->getName());
        if ($path !== $value) {
            return $value;
        }

        return $this->translator->translate($path);
    }
1287217
protected static function encodePath(string $path): string
    {
        // http://tools.ietf.org/html/rfc3986#section-3.3
        // path          = path-abempty    ; begins with "/" or is empty
        //               / path-absolute   ; begins with "/" but not "//"
        //               / path-noscheme   ; begins with a non-colon segment
        //               / path-rootless   ; begins with a segment
        //               / path-empty      ; zero characters
        //
        // path-abempty  = *( "/" segment )
        // path-absolute = "/" [ segment-nz *( "/" segment ) ]
        // path-noscheme = segment-nz-nc *( "/" segment )
        // path-rootless = segment-nz *( "/" segment )
        // path-empty    = 0<pchar>
        // segment       = *pchar
        // segment-nz    = 1*pchar
        // segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
        //               ; non-zero-length segment without any colon ":"
        // pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
        $excluded = static::UNRESERVED_SET.static::SUB_DELIMS_SET.':@\/';

        return static::encode($path, $excluded);
    }
235012
private function getFileExtension($path) {
		if (empty($path)) return '';
		$ext = pathinfo($path, PATHINFO_EXTENSION);
		return strtolower($ext); 
	}
227005
public static function url(string $path): string
    {
        return self::SCHEME . '://' . join(
                '/',
                array_map(
                        'rawurlencode',    // ensure singe path parts are correctly urlencoded
                        explode(
                                '/',
                                str_replace('\\', '/', $path)  // ensure correct directory separator
                        )
                )
        );
    }