PHPackages                             muvon/kiss-money - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. muvon/kiss-money

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

muvon/kiss-money
================

KISS implementation of Money manipuliation logic

0.5.0(1mo ago)233MITPHPPHP &gt;=8.0

Since Mar 14Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Muvon/php-kiss-money)[ Packagist](https://packagist.org/packages/muvon/kiss-money)[ RSS](/packages/muvon-kiss-money/feed)WikiDiscussions master Synced yesterday

READMEChangelog (9)Dependencies (2)Versions (10)Used By (0)

php-kiss-money
==============

[](#php-kiss-money)

KISS implementation of Money manipulation with configuring currencies byself

Simple usage
------------

[](#simple-usage)

```
use Muvon\KISS\Money;
Money::init([
  'USD' => [
    'fraction' => 2
  ]
]);

$Money = Money::fromAmount('0.01', 'USD');

// If we want to create from minor amount (aka value)
// $Money = Money::fromValue('1', 'USD');
// Get amount
var_dump($Money->getAmount());

// Get minor amount aka Value
var_dump($Money->getValue());
```

Methods
-------

[](#methods)

### Initialize

[](#initialize)

Before usage of Money object you need to configure it with your currencies.

To do this just invoke Money::init() method with passed config to it before startup of your application.

Example of initializing the object:

```
use Muvon\KISS\Money;
$config = [
  'USD' => [
    'fraction' => 2
  ],
  'EUR' => [
    'fraction' => 2
  ]
];
Money::init($config);
```

### Create from amount of currency

[](#create-from-amount-of-currency)

You can create object using amount or value (aka minor amount) as single instance and also as from list of instances (array);

Look at example usage below to understand how you can create objects.

```
$list = Money::fromAmounts(['1.01', '2.03'], 'USD');
// Dumps array of Money objects created from amounts
var_dump($list);

// Dumps single object from amount
var_dump(Money::fromAmount('1.01', 'USD'));

// You can do almost the same just from minor amount
// Using method fromValue and fromValues
// But passing minor amounts to them
```

### Mathematic operations

[](#mathematic-operations)

Available operations with 2 objects of money - add and sub.

Example:

```
$one = Money::fromAmount('1.5', 'USD');
$two = Money::fromAmount('2.0', 'USD');

// Dumps "3.50"
var_dump($one->add($two));

// Dumps "0.50"
var_dump($two->sub($one));
```

You also can multiply or divide using methods mul and div.

Example:

```
$usd = Money::fromAmount('1.5', 'USD');

// Dumps "3.00"
var_dump($usd->mul('2'));

// Dumps "0.75"
var_dump($usd->div('2'));
```

### Convert to another country

[](#convert-to-another-country)

The library supports conversion from one to another country in rate of presented by another country.

To convert just call cnv methods as follows in example.

Example:

```
$xrp = Money::fromAmount('23.00243', 'XRP');
$rate = Money::fromAmount('0.51', 'USD'); // How much for 1 XRP

// Dumps "11.73"
var_dump($xrp->cnv($rate));
```

To make conversions easier you can also create your rate using 2 same currency objects.

Example:

```
$Source = Money::fromAmount('0.5', 'USD');
$Target = Money::fromAmount('10', 'USD');

// Dumps object with rate "20"
var_dump(Money::rate($Source, $Target, 'XRP'));
```

### Comparing operations

[](#comparing-operations)

All comparing operations are named as bash-like style.

MethodDescriptioneqEqualsneNot equalsgtGreater thangeGreater or equalltLess thanleLess than or equalAll methods has only 1 arg should be passed – another object of Money to compare with current one.

Example:

```
$one = Money::fromAmount('1.5', 'USD');
$two = Money::fromAmount('2', 'USD');

// Dumps false
var_dump($one->ge($two));

// Dumps true
var_dump($one->lt($two));
```

### Self checking methods

[](#self-checking-methods)

You can check current value with methods – isPositive, isNegative, isZero.

Example:

```
$usd = Money::fromAmount('1.5', 'USD');

// Dumps true
var_dump($usd->isPositive());

// Dumps false
var_dump($usd->isNegative());

// Dump false
var_dump($usd->isZero());
```

### Getting information about current object

[](#getting-information-about-current-object)

You can use next method to get current state of object and its value. All methods have no arguments

MethodArgumentsReturnDescriptiongetAmount-stringReturn current amount presentation of value with configured fraction as a stringgetValue-stringReturn current minor amount (called value) of current objectgetCurrency-stringReturn current currency of of this object### Use as string

[](#use-as-string)

You can use object as string. By default it returns Money::getAmount() method call.

Dependecies
-----------

[](#dependecies)

This library requires you to have bcmath and gmp extension and PHP 8+ version.

This library has no other code dependencies and kept as simple as possible.

Test coverage
-------------

[](#test-coverage)

- Can create single
- Can create multiple
- Can create zero
- Cannot create no config
- Add sub operations
- Mul div operations
- Rate calculation
- Convert to another currency
- Cannot convert same currency
- Result is immutable
- Cmp operations
- Cannot add sub different currency
- Cannot compare different currency
- Is positive
- Is negative
- Is zero
- Has currency
- Can use as string

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance52

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~238 days

Recently: every ~477 days

Total

9

Last Release

30d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/63024506f19e213d456eab6179ffa1e95d5f2b4ee19aa06063f754a4cb3f113d?d=identicon)[muvon](/maintainers/muvon)

---

Top Contributors

[![donhardman](https://avatars.githubusercontent.com/u/59067742?v=4)](https://github.com/donhardman "donhardman (31 commits)")

---

Tags

moneycurrencylightweightvalueamountkiss

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/muvon-kiss-money/health.svg)

```
[![Health](https://phpackages.com/badges/muvon-kiss-money/health.svg)](https://phpackages.com/packages/muvon-kiss-money)
```

###  Alternatives

[brick/money

Money and currency library

1.9k41.8M157](/packages/brick-money)[florianv/swap

PHP currency conversion library for retrieving exchange rates from 30+ providers, with caching and fallback.

1.3k6.8M23](/packages/florianv-swap)[cknow/laravel-money

Laravel Money

1.0k4.8M31](/packages/cknow-laravel-money)[akaunting/laravel-money

Currency formatting and conversion package for Laravel

7865.8M47](/packages/akaunting-laravel-money)[kwn/number-to-words

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

4375.4M23](/packages/kwn-number-to-words)[torann/currency

This provides Laravel with currency functions such as currency formatting and conversion using up-to-date exchange rates.

4031.1M6](/packages/torann-currency)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
