gecleanme/xkunverio

Unit Conversions made a breeze

2.1.2 2024-04-07 08:12 UTC

This package is auto-updated.

Last update: 2025-01-07 10:23:20 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Zero-dependency, slim Laravel package to convert between different units with ease

Installation

You can install the package via composer:

composer require gecleanme/xkunverio

Usage

// use the designated Conversion Type Class & its corresponding Enum following the naming pattern :
//"X{ConversionType}" & "X{ConversionType}Unit" for the Enum

use gecleanme\Xkunverio\Enums\XLengthUnit;
use gecleanme\Xkunverio\XLength;

// Invoke the 'convert' method with the "unit from", "unit to" and the measurement value then call
// get()

// Convert one Kilometer to Meters
XLength::convert(XLengthUnit::Kilometer, XLengthUnit::Meter, 1)
    ->get(); //1000.0

Testing

composer test

Supported Length Units

  • Meter
  • Kilometer
  • Mile
  • Yard
  • Centimeter
  • Inch
  • Feet
  • Millimeter

Supported Area Units

  • Square Inches
  • Square Feet
  • Square Yards
  • Square Miles
  • Square Millimeter
  • Square Centimeter
  • Square Meters
  • Square Kilometers

Supported Mass Units

  • Kilograms
  • Ounces
  • Pounds
  • Stones
  • Long Tonnes
  • Short Tonnes
  • Milligrams
  • Grams
  • Metric Tonnes

Supported Speed Units

  • Meters Per Second
  • Kilometers Per Hour
  • Miles Per Hour
  • Knots

Supported Temperature Units

  • Celsius
  • Fahrenheit
  • Kelvin

Supported Volume Units

  • Cubic Inches
  • Cubic Feet
  • Cubic Centimeters
  • Milliliters
  • Cubic Meters
  • Imperial Gallons
  • Imperial Quarts
  • Imperial Pints
  • Imperial Cups
  • Imperial Ounces
  • Imperial Tablespoons
  • Imperial Teaspoons
  • Liters

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Report them by Emailing me

Credits

License

The MIT License (MIT). Please see License File for more information.