luqmanrom / ringgit

Malaysia Ringgit implementation on top of Money PHP

Home Page:https://packagist.org/packages/jomweb/ringgit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Malaysia Ringgit implementation on top of Money PHP

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

PHP 7.0+ library to make working with money safer, easier, and fun for Malaysia Ringgit!

"If I had a dime for every time I've seen someone use FLOAT to store currency, I'd have $999.997634" -- Bill Karwin

In short: You shouldn't represent monetary values by a float. Wherever you need to represent money, use this Money value object.

<?php

use Duit\MYR;

$fiveMyr = MYR::given(500);
$tenMyr = $fiveMyr->add($fiveMyr);

list($part1, $part2, $part3) = $tenMyr->allocate(array(1, 1, 1));
assert($part1->equals(MYR::given(334)));
assert($part2->equals(MYR::given(333)));
assert($part3->equals(MYR::given(333)));

Installation

To install through composer, simply put the following in your composer.json file:

{
    "require": {
        "jomweb/ringgit": "^0.2"
    }
}

And then run composer install from the terminal.

Quick Installation

Above installation can also be simplify by using the following command:

composer require "jomweb/ringgit"

Usages

Declaration

Without GST

use Duit\MYR;

$money = new MYR(540);
$money = MYR::given(540);
$money = MYR::withoutVat(540);

Before GST

use Duit\MYR;

$money = MYR::beforeVat(540);

After GST

use Duit\MYR;

$money = MYR::afterVat(530);

About

Malaysia Ringgit implementation on top of Money PHP

https://packagist.org/packages/jomweb/ringgit

License:MIT License


Languages

Language:PHP 100.0%