Realtive Path

@param string $string

@return string
192934
public static function relativepath(String $string) : String
    {
        return str_replace(REAL_BASE_DIR, NULL, self::originpath($string));
    }
8269
public static function up($string): string
    {
        $cleaned = Str::up($string);
        $cleaned = Str::trim($cleaned);

        return $cleaned;
    }
1106244
private function makePathRelative (string $path) : string
    {
        return ($this->projectDir === substr($path, 0, strlen($this->projectDir)))
            ? substr($path, strlen($this->projectDir) + 1)
            : $path;
    }
1050516
public static function realpath($path) {
    if (file_exists($path)) {
      return str_replace("\\", "/", realpath($path));
    }
    $path = str_replace("\\", "/", $path);
    $parts = array_filter(explode("/", $path), 'strlen');
    $absolutes = [];
    foreach ($parts as $part) {
      if ('.' == $part) {
        continue;
      }
      if ('..' == $part) {
        array_pop($absolutes);
      }
      else {
        $absolutes[] = $part;
      }
    }
    $result = implode("/", $absolutes);
    if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
      $result = '/'.$result;
    }
    return $result;
  }
1081521
public static function fixPath(string $path): string
    {
        if (false !== strpos($path, '\\')) {
            $path = str_replace('\\', '/', $path);
        }
        while (false !== strpos($path, '//')) {
            $path = str_replace('//', '/', $path);
        }
        if (strlen($path)) {
            if ('/' === substr($path, 0, 1)) {
                $path = ltrim($path, '/');
            }
            if ('/' === substr($path, -1, 1)) {
                $path = rtrim($path, '/');
            }
        }

        return $path;
    }
912047
protected function realpath($path)
    {
        $realpath = $path;
        if (strpos($realpath, '~') === 0 && ($homedir = $this->getUserHomeDir())) {
            $realpath = $homedir . substr($realpath, 1);
        }
        $realpath = realpath($realpath);

        if ($realpath === false) {
            throw new \Exception(sprintf('Could not determine real path of %s.', $path));
        }

        return $realpath;
    }
838611
public function resolveLinksInString($string)
    {
        return preg_replace_callback(
            '/(?<!\\\){@(.*?)}/',
            function ($matches) {
                try {
                    return $this->offsetGet($matches[1]);
                } catch (\OutOfBoundsException $e) {
                    return $matches[0];
                }
            },
            $string
        );
    }
1349284
public function getRealpath($path)
    {
        $path   = $this->applyPathPrefix($path);
        $s3path = sprintf("s3://%s/%s", $this->getBucket(), $path);

        return $s3path;
    }
1162102
public function absoluteUrlFilter($string)
    {
        $url    = $this->grav['uri']->base();
        $string = preg_replace('/((?:href|src) *= *[\'"](?!(http|ftp)))/i', "$1$url", $string);

        return $string;

    }
800043
public static function ucfirst(string $string): string
    {
        return self::strtoupper(self::substr($string, 0, 1)) . self::substr($string, 1);
    }
124159
public function pathSafeFilename($string)
	{
		$string = str_replace(
			array_merge(range(chr(0), chr(31)), str_split("#%+&`‘/<>:\"|?*\x5C\x7F")),
			' ',
			trim($string)
		);
		$string = Utf8::filter($string);
		$string = preg_replace('/\s{2,}/', ' ', $string);
		$string = str_replace(array(' ', '%20'), '_', $string);
		return $string;
	}
1314733
public function realpath($file)
    {
        $prefix = preg_quote($this->_prefix, '~');
        $file = preg_replace("~^{$prefix}~", '', $file);
        if (!$this->_hasVolume) {
            return $file;
        }
        if (preg_match('~^[A-Z]+:~', $file)) {
            return $file;
        }
        $file = ltrim($file, DS);
        $pos = strpos($file, DS);
        if ($pos !== false) {
            $file = substr_replace($file, ':' . DS, $pos, 1);
        }
        return $file;
    }
618379
static function fromString(string $string): self
    {
        $string = str_replace("/", "\\", $string);
        $string = preg_replace("#(\\\\){2,}#", "\\", $string);
        if (substr($string, -1, 1) == "\\") {
            $string = substr($string, 0, -1);
        }
        
        return new self($string);
    }
1183324
public static function ucfirst($string)
    {
        switch (static::strlen($string)) {
            case 0:
                return '';
            case 1:
                return static::strtoupper($string);
            default:
                return static::strtoupper(static::substr($string, 0, 1)) . static::substr($string, 1);
        }
    }
8348
public function getString($string)
    {
        // Exact match?
        if (isset($this->strings[$string])) {
            return $this->strings[$string];
        } else {
            return $string;
        }
    }
1164392
protected static function _realpath($path)
    {
        $realPath = realpath($path);
        if ($realPath !== false) {
            $path = $realPath;
        }

        return rtrim($path, '/\\');
    }
182405
public function friendlyUrl($string)
    {
        /**
         * @var Helper $helper
         */
        $helper = $this->helper;

        $string = preg_replace('~[\s\t\n\r]+~', '-', $string);

        $string = $helper->str()->low($string);
        $string = $helper->str()->translit($string);

        return trim(preg_replace('~[^a-z0-9-]+~', '', $string), '-');
    }