PHP code example of twifty / path

1. Go to this page and download the library: Download twifty/path library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

twifty / path example snippets


$this->path = rtrim($path, '/').'/';

class Path
{
    /**
     * Removes '.', '..' and terminating '/' from path.
     * 
     * Also collapses multiple concurrent '/' characters.
     *
     * @param string $path
     *
     * @return string
     */
    public static function normalize(string $path): string;

    /**
     * Checks if $path has a valid prefix.
     *
     * @param string $path
     *
     * @return bool
     */
    public static function isAbsolute(string $path): bool;

    /**
     * Returns the absolute prefix of $path.
     *
     * For Unix style paths '/' is returned, for windows, 'c:/'
     * and for wrappers, the full scheme 'vfs://'. An empty
     * string is returned for relative paths.
     *
     * @param string $path
     *
     * @return string
     */
    public static function getPrefix(string $path): string;

    /**
     * Returns the directories/filename component of $path.
     * 
     * The returned path is fully normalized.
     *
     * @param string $path
     *
     * @return string
     */
    public static function getHierarchy(string $path): string;

    /**
     * Returns both prefix and hierarchy of $path.
     *
     * @param string $path
     *
     * @return array
     */
    public static function split(string $path): array;

    /**
     * Appends to and normalizes $path.
     *
     * @param string $path
     * @param string $append
     *
     * @throws PathException
     *
     * @return string
     */
    public static function append(string $path, string $append): string;

    /**
     * Returns the normalized parent directory of $path.
     *
     * @param string $path
     *
     * @return string
     */
    public static function dirname(string $path): string;
    
    /**
     * Calculates the path between $source and $target.
     * 
     * @param string $source
     * @param string $target
     * @return string
     * @throws PathException
     */
    public static function relativeTo(string $source, string $target): string;
}