PHPackages                             lucasjs7/convert-data-size - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. lucasjs7/convert-data-size

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

lucasjs7/convert-data-size
==========================

This is a simple and lightweight library that aims to convert computational data using PHP language.

v1.0(1y ago)1351MITPHP

Since Nov 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/lucasjs7/convert-data-size)[ Packagist](https://packagist.org/packages/lucasjs7/convert-data-size)[ RSS](/packages/lucasjs7-convert-data-size/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (1)

Convert Data Size for PHP
=========================

[](#convert-data-size-for-php)

This is a simple and lightweight library that aims to convert computational data using PHP language.

Install using composer
======================

[](#install-using-composer)

```
composer require lucasjs7/convert-data-size
```

Available functions
===================

[](#available-functions)

- [Parser](#parser)
    - [Function](#parser-function)
    - [Parameters](#parser-parameters)
    - [Examples](#parser-examples)
- [Unit](#unit)
    - [Function](#unit-function)
    - [Parameters](#unit-parameters)
    - [Examples](#unit-examples)

Parser
======

[](#parser)

With this function you can pass the quantity and the measurement in the same string and define the output measurement. If the input or output measurement is not in the list of [supported measurements](#supported-measures), the return will be false.

### Function

[](#function-)

```
class ConvertDataSize {

	public static function parser(string $value, string $toSize = 'B', ?int $scale = 2): string|false;

}
```

### Parameters

[](#parameters-)

- **value**: The string containing the quantity with the computational unit
- **toSize**: The measure of result
- **scale**: Sets the number of digits after the decimal place of the result

### Examples

[](#examples-)

```
