Money

Money class for your applications

Handling Money with PHP is not so fun and game, is it?

To build a great app, you have to have a great abstraction ahead for the Money type, especially if your apps are going to work closely with the money, eg:

  • Finance

  • E-commerce

  • Logistic

  • ...

Worry not, ShipSaaS got your back with the Moneyclass, features:

  • Immutable by default, money is pretty important, ya know.

  • Super lightweight yet strong helper

Glossary

Money class use int and stores your money as cents. So:

  • $6 => 600

  • $5.99 => 599

  • ...

In this way, we will never get the "floating-point" issues (for all langs & DB engines)

Usage

Create a new Money instance

Clone

Aggregators

There are some built-in methods that would help you to do the math:

Present

You also can get the human-readable text to show up to your users.

It will generate the text based on the currencies configuration.

Last updated