Skip to content

ramazancetinkaya/byte-formatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Byte Formatter Library

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.