timostamm/pathinfo

An object to manipulate filesystem paths with a fluid interface

v1.1.0 2023-05-08 10:39 UTC

This package is auto-updated.

Last update: 2024-05-08 15:22:30 UTC


README

build Packagist PHP Version GitHub tag License

An object to manipulate filesystem paths with a fluid interface.

Example

$root = Path::info('/var/wwwroot/index.html');

$root->equals('/foo/../var/root/index.html'); // -> true
$root->isIn('/var/wwwroot/'); // -> true
$root->isAbsolute(); // -> true

$root->dirname(); // -> "/var/wwwroot/"
$root->filename(); // -> "index.html"
$root->basename(); // -> "index"
$root->extension(); // -> "html"

Path::info('../log.txt')
	->abs($root)
	->get(); // -> "/var/log.txt"

Path::info('/foo/../var/root/index.html')
	->normalize()
	->get(); // -> "/var/wwwroot/index.html"