bitandblack/pathinfo

Easy handling of path information in an object-oriented way.

1.0.4 2024-11-26 07:46 UTC

This package is auto-updated.

Last update: 2024-11-26 07:46:38 UTC


README

PHP from Packagist Latest Stable Version Total Downloads License

Bit&Black PathInfo

Easy handling of path information in an object-oriented way.

Installation

This library is made for the use with Composer. Add it to your project by running $ composer require bitandblack/pathinfo.

Usage

Initialize the PathInfo with a path:

<?php

use BitAndBlack\PathInfo\PathInfo;

$pathInfo = new PathInfo('/path/to/myfile.jpg');

You can access the single parts of the path now like that:

<?php

/** Will echo "myfile" */
echo $pathInfo->getFileName();

/** Will echo "jpg" */
echo $pathInfo->getExtension();

You can also modify the parts:

<?php

use BitAndBlack\PathInfo\PathInfo;

$pathInfo = new PathInfo('/path/to/myfile.jpg');

/** Will echo "/path/to/myfile.jpg" */
echo $pathInfo->getFilePath();

$pathInfoModified = $pathInfo
    ->withFileNameAppended('-modified')
    ->withExtension('png')
;

/** Will echo "/path/to/myfile-modified.png" */
echo $pathInfoModified->getFilePath();

Help

If you have any questions, feel free to contact us under hello@bitandblack.com.

Further information about Bit&Black can be found under www.bitandblack.com.