nickbeen/nintendo-blocks-converter

Convert Nintendo blocks to Megabytes and vice versa

1.2.0 2023-05-03 13:38 UTC

This package is auto-updated.

Last update: 2024-11-18 21:41:19 UTC


README

Latest version Build status Total downloads PHP Version License

With this library you can convert Nintendo blocks to the actual filesize in Megabytes. It's also possible to convert the filesize in Megabytes to Nintendo blocks. No longer need to think twice whether you need to divide or multiply by 8, unless you've memorized 1 Nintendo block equals 1 Megabit.

Nintendo blocks are only applicable to applications for the Nintendo DS, Nintendo Wii and Nintendo 3DS consoles.

Requirements

  • PHP >= 8.0

Installation

Install the library into your project with Composer.

composer require nickbeen/nintendo-blocks-converter

Usage

Initiate a NintendoConverter model with either a specified number of blocks or Megabytes and call the method containing the desired unit to convert to. The library throws a UnnecessaryCalculationException when converting blocks to blocks or Megabytes to Megabytes. Implement a try block to handle the exception in your application in the best possible way.

Blocks to MB

Convert a specified number of blocks to a filesize in Megabytes.

$blocks = new NintendoConverter(blocks: 80);

return $blocks->toMegabytes(); // returns 10

MB to blocks

Convert a specified filesize in Megabytes to a number of blocks.

$megabytes = new NintendoConverter(megabytes: 80);

return $megabytes->toBlocks(); // returns 640

License

This library is licensed under the MIT License (MIT). See the LICENSE for more details.