Trim file name from provided path

@param string $path

@return string
971609
public static function trimFileName($path)
    {
        $name = static::nameFromPath($path);

        return substr($path, 0, strlen($path) - strlen($name));
    }
27883
public function getPrefixedPath(string $path = '') : string
  {
    return trim($this->parent ? 
      ($this->parent->getPrefixedPath($this->prefix ? $this->prefix . '/' . $path : $path)) :
      ($this->prefix ? $this->prefix . '/' . $path : $path), '/');
  }
791895
static function sanify_path($path) {
            $path = rtrim(str_replace('\\', '/', $path), '/').'/';
            do {
                $old_path = $path;
                $path = str_replace('//', '/', str_replace('/./', '/', $path));
            } while ($path != $old_path);
            do {
                $path = preg_replace('_/([^/]+?)/\\.\\./_', '/', $path, -1, $count);
            } while ($count > 0);
            $path = rtrim($path, '/');

            return $path;
        }
220344
protected function sanitizePath($path)
    {
        $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);

        $path = preg_replace('/'.preg_quote('./', '/').'/', '', $path, 1);
        $path = trim($path, '/');

        return $path;
    }
1316763
public function text($path = '.', $trim = true)
    {
        $text = strval($this->first($path));

        return $trim ? trim($text) : $text;
    }
1058400
private function cleanPath($path)
  {
    $path = substr($path, 0, 1) == '/' ? substr($path, 1, strlen($path) - 1) : $path;
    $path = substr($path, strlen($path) - 1, 1) == '/' ? substr($path, 0, strlen($path) - 1) : $path;

    $path = substr($path, 0, 1) == '\\' ? substr($path, 1, strlen($path) - 1) : $path;
    $path = substr($path, strlen($path) - 1, 1) == '\\' ? substr($path, 1, strlen($path) - 1) : $path;

    $path = preg_replace('#' . $this->DS . '+#', $this->DS, $path);

    return $path;
  }
564242
public static function normalizePath($path)
    {
        $path = rtrim($path, '/');
        $path = rtrim($path, '\\');
        $path .= DIRECTORY_SEPARATOR;
        return $path;
    }
808377
public static function getAbsolutePath(string $path): string
    {
        $parts = \preg_split('~[/\\\\]+~', $path, 0, \PREG_SPLIT_NO_EMPTY);
        $absolutes = [];
        foreach ($parts as $part) {
            if ('.' === $part) {
                continue;
            }
            if ('..' === $part) {
                \array_pop($absolutes);
            } else {
                $absolutes[] = $part;
            }
        }

        /**
         * Allows to dereference char
         */
        $__FILE__ = \preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__);// remove file protocols such as "phar://" etc.
        $prefix = $__FILE__[0] === \DIRECTORY_SEPARATOR ? \DIRECTORY_SEPARATOR : '';
        return $prefix . \implode(\DIRECTORY_SEPARATOR, $absolutes);
    }
155402
private function normalize(string $path): string
    {
        if ($path === '') {
            return '/';
        }

        if (strlen($path) > 1) {
            if ($this->trailingSlash) {
                if (substr($path, -1) !== '/' && !pathinfo($path, PATHINFO_EXTENSION)) {
                    return $path.'/';
                }
            } else {
                return rtrim($path, '/');
            }
        }

        return $path;
    }
62617
public static function stripQueryString($path)
    {
        if (($qpos = strpos($path, '?')) !== false) {
            return substr($path, 0, $qpos);
        }
        return $path;
    }
951838
public static function normalizePath( $path )
    {
        if ( '\\' == DIRECTORY_SEPARATOR )
        {
            if ( isset( $path, $path[1], $path[2] ) && ':' === $path[1] && '\\' === $path[2] )
            {
                if ( false !== strpos( $path, '/' ) )
                {
                    $path = str_replace( '/', DIRECTORY_SEPARATOR, $path );
                }
            }
        }

        return $path;
    }
661695
function removePathPrefix($path)
    {
        if (strpos($path, $this->getPathPrefix()) === false) {
            return basename($path);
        }

        return parent::removePathPrefix($path);
    }
1144400
protected function splitPath($path)
    {
        $lastSlashPos = strrpos($path, '/');
        if (false === $lastSlashPos) {
            return array('dirname' => '', 'basename' => $path);
        }

        return array('dirname'  => substr($path, 0, $lastSlashPos),
                     'basename' => substr($path, $lastSlashPos + 1)
               );
    }
271172
public static function cleanPath($path)
    {
        $regex = '/(\/)\/+/';
        $path = str_replace(['\\', '/ /'], '/', $path);
        $path = preg_replace($regex,'$1',$path);

        return $path;
    }
470872
public static function dirname($path)
    {
        if (strpos($path, '\\') === false) {
            return dirname($path);
        }
        return str_replace('/', '\\', dirname(str_replace('\\', '/', $path)));
    }
52182
protected function normalizeFilename($path)
    {
        if (file_exists($path)) {
            $path = realpath($path);
        }
        return str_replace(base_path(), '', $path);
    }
1034498
public final function clean_path($path) {

        $path = rtrim($path, DIRECTORY_SEPARATOR);

        $parttoremove = DIRECTORY_SEPARATOR . 'tests';

        $substr = substr($path, strlen($path) - strlen($parttoremove));
        if ($substr == $parttoremove) {
            $path = substr($path, 0, strlen($path) - strlen($parttoremove));
        }

        return rtrim($path, DIRECTORY_SEPARATOR);
    }