ramazancetinkaya/byte-formatter

A PHP library to format bytes into human-readable format and vice versa.

1.0.0 2023-12-29 14:02 UTC

This package is auto-updated.

Last update: 2024-10-29 22:49:29 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

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 this library via Composer. Run the following command:

composer require ramazancetinkaya/byte-formatter

Usage

<?php

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

use ramazancetinkaya\ByteFormatter;

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

// Format bytes
echo $formatter->format(2048); // Output: 2 KB

// Convert from human-readable size to bytes
echo $formatter->convertToBytes('2 KB'); // Output: 2048

Contributing

Contributions are welcome! Please fork the repository and create a pull request.

License

This project is licensed under the MIT License. For more details, see the LICENSE file.