Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ankitjain28may/prettysize
https://github.com/ankitjain28may/prettysize
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ankitjain28may/prettysize
- Owner: ankitjain28may
- License: mit
- Created: 2018-11-24T10:13:46.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-12T06:02:00.000Z (about 5 years ago)
- Last Synced: 2024-04-14T06:10:30.623Z (7 months ago)
- Language: PHP
- Size: 189 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# About prettysize
prettysize was created by, and is maintained by [Ankit Jain](https://github.com/ankitjain28may), and is a helper utility to provide pretty printed file sizes.
[![Build Status](https://travis-ci.org/ankitjain28may/prettysize.svg?branch=master)](https://travis-ci.org/ankitjain28may/prettysize)
[![Coverage Status](https://coveralls.io/repos/github/ankitjain28may/prettysize/badge.svg?branch=master)](https://coveralls.io/github/ankitjain28may/prettysize?branch=master)
[![Latest Stable Version](https://poser.pugx.org/ankitjain28may/prettysize/v/stable)](https://packagist.org/packages/ankitjain28may/prettysize)## Installation & Usage
> **Requires [PHP 7.1+](https://php.net/releases/)**
Require prettysize using [Composer](https://getcomposer.org):
```bash
composer require ankitjain28may/prettysize
```### Arguments
```php
Pretty::pretty($size, $nospace, $one, $places);/*
$size : Size in bytes to be converted (Required)
$nospace : Remove space from the output (Default - false)
$one : Single character for the size (Default - false)
$places : Number of decimal places to return (Default - 1)
*/
``````php
use Ankitjain28may\Prettysize\Pretty;$size = Pretty::pretty(1024);
// $size = "1.0 kB"$size = Pretty::pretty(1024, true, true, 2);
// $size = "1.00k"$size = Pretty::pretty(1024, ['nospace' => true, 'one' => true, 'places' => 5]);
// $size = "1.00000k"
```## Contributing
Thank you for considering to contribute to prettysize.
You can also follow the twitter account for latest announcements or just come say hi!: [@ankitjain28may](https://twitter.com/ankitjain28may)## License
prettysize is an open-sourced library licensed under the [MIT license](LICENSE.md).