PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Rafal Janisz   PHP File Size to Human Readable   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP File Size to Human Readable
Calculate the size of files and directories
Author: By
Last change:
Date: 4 years ago
Size: 1,489 bytes
 

Contents

Class file image Download

objectsize

Build Status codecov

Converts file or directory to human readable number by taking the number of that unit that the bytes will go into it.

Requirements

  • PHP >= 7.1
  • ravjanisz/readablesize
  • (optional) PHPUnit to run tests.

Install

Via Composer:

$ composer require ravjanisz/objectsize

Usage

//settings and object instance
use Rav\Size\SizeSettings;
use Rav\ObjectSize\ObjectSize;

//create settings for human readable size
$settings = new SizeSettings();
$settings->setPrecision(2);

//create object instance
$object = new ObjectSize($settings);
//set file/dir path
$object->setPath(__DIR__ . '/files/shark.jpeg');
//get value
echo $object->human();
//get value in bytes
echo $object->inBytes();

//set file/dir path
$object->setPath(__DIR__ . '/files');
//get value
echo $object->human();
//get value in bytes
echo $object->inBytes();

Documentation

None

Support the development

Do you like this project? Support it by donating

<a href="https://www.buymeacoffee.com/ravjanisz">

alt Buy me a coffee

</a>

License

objectsize is licensed under the MIT License - see the LICENSE file for details