bitandblack/pathinfo

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

0.0.2 2021-06-02 14:07 UTC

This package is auto-updated.

Last update: 2021-09-02 15:00:59 UTC


README

PHP from Packagist Codacy Badge 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.