bitandblack / pathinfo
Easy handling of path information in an object-oriented way.
1.0.3
2023-07-21 09:36 UTC
Requires
- php: >=7.4
Requires (Dev)
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^10.0
- rector/rector: ^0
- symplify/easy-coding-standard: ^11.0
README
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.