eugabrielsilva/currency

PHP currency manipulation class.

Maintainers

Package info

github.com/eugabrielsilva/currency

pkg:composer/eugabrielsilva/currency

Statistics

Installs: 23

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2025-02-03 15:55 UTC

This package is auto-updated.

Last update: 2026-02-28 15:27:21 UTC


README

This package is a translation of currency.js for PHP. It was built to work around floating point issues when working with currency values.

Currency works with values as integers behind the scenes, resolving some of the most basic precision problems.

Installation

composer require eugabrielsilva/currency

Usage

With real numbers:

$result = currency(3.2)->multiply(0.5)->add(1)->value;

With currency instances:

$value1 = currency(3.2);
$value2 = currency(0.5);
$value3 = currency(1);

$result = $value1->multiply($value2)->add($value3)->value;

Formatting:

$value = currency(3.2)->multiply(0.5)->add(1);

echo $value->format();