A simple path formatter.
composer require kiryi/pathyi
$pathyi = new \Kiryi\Pathyi\Formatter();
$path = $pathyi->format($path);
format(string $path, bool $leadingSlash = false, bool $trailingSlash = false): string
path
The path to format. If only backslashes appearing, path will be returned with leading/trailing backslashes. If not, forward slashes are used.
leadingSlash
Defines if the returned path starts with a slash (true) or not (false, default).
trailingSlash
Defines if the returned path ends with a slash (true) or not (false, default).
Returns the formatted path as a string.
$path = '/this/is/my/path';
$pathyi = new \Kiryi\Pathyi\Formatter();
$path = $pathyi->format($path);
// $path is now 'this/is/my/path'
$path = $pathyi->format($path, true);
// $path is now '/this/is/my/path'
$path = $pathyi->format($path, false, true);
// $path is now 'this/is/my/path/'