ramazancetinkaya/byte-formatter

A professional library for formatting byte values into human-readable strings.

1.0.0 2024-12-19 15:55 UTC

This package is auto-updated.

Last update: 2024-12-19 15:56:55 UTC


README

License Version PHP GitHub stars

A PHP library that formats bytes into a human-readable format and vice versa.

Report a Bug · New Pull Request

🚀 Give this Project a Star

If you found this library useful or would like to support it, please consider giving it a star on GitHub! Your support helps improve and maintain the project. Thank you! 🌟

Overview

This library provides functionality to convert bytes into a human-readable format and vice versa. It allows customization of formatting options and supports error handling for invalid inputs.

Installation

You can install the ByteFormatter library using Composer. Run the following command in your terminal:

composer require ramazancetinkaya/byte-formatter

Usage

Here is a simple example of how to use the ByteFormatter class:

<?php

require 'vendor/autoload.php'; // Composer autoload file

use ramazancetinkaya\ByteFormatter;

// Create an instance of ByteFormatter
$formatter = new ByteFormatter();

// Format bytes
echo $formatter->formatBytes(123456789); // Outputs: 117.74 MB

// Convert from human-readable size to bytes
echo $formatter->parseFormattedValue('1.5 GB'); // Outputs: 1610612736

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for more details.