Skip to content

aschmelyun/size

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Size

Current Version License Total Downloads

🧮 A super simple helper package for converting between different byte units.

composer require aschmelyun/size

Requirements

  • PHP 7.4 or higher

Usage

Instantiate the class with the data unit you're bringing in. By default, it'll return back the value in bytes. You can then tack on either a method or a property to convert that unit into a different one.

use Aschmelyun\Size\Size;

$bytesInTwoMegabytes = Size::MB(2); // 2097152

$gigabytesInTwoMegabytes = Size::MB(2)->toGB(); // 0.001953125

$kilobytesInTwoMegabytes = Size::MB(2)->KB; // 2048

That's it!

The available properties are: B, KB, MB, GB, TB, PB, EB, ZB, YB

Tests

Size comes with a small suite of tests powered by Pest. To run them, clone this repository and then use:

./vendor/bin/pest

Contact Info

Have an issue? Submit it here! Want to get in touch or recommend a feature? Feel free to reach out to me on Twitter for any other questions or comments.

License

The MIT License (MIT). See LICENSE.md for more details.

About

Simple PHP helper to convert bytes to different sizes

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages