PHPackages                             philipbrown/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. philipbrown/money

Abandoned → [money/money](/?search=money%2Fmoney)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

philipbrown/money
=================

Shameless port of RubyMoney

v1.0.0(12y ago)82151MITPHPPHP &gt;=5.3.2

Since Apr 26Pushed 11y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (1)

Money (DEPRECATED)
==================

[](#money-deprecated)

**Shameless port of [RubyMoney](https://github.com/RubyMoney/money)**

[![Build Status](https://camo.githubusercontent.com/e4eac8406efda9e88f0987d3ef6e94d4d50f3a41104a8f028b05f4cb2a107b14/68747470733a2f2f7472617669732d63692e6f72672f7068696c697062726f776e2f6d6f6e65792e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/philipbrown/money)

`Money` is a PHP class that allows you to easily work with money within your application including it's value and currency. Each currency has it's associated information encapsulated with a seperate `Currency` class.

Values are represented as integers in cents to avoid floating point rounding errors.

Return values are immutable value objects.

Installation
------------

[](#installation)

Add `philipbrown/money` as a requirement to `composer.json`:

```
{
  "require": {
    "philipbrown/money": "1.*"
  }
}
```

Update your packages with `composer update`.

Usage
-----

[](#usage)

To create a new `Money` object you either instantiate like you normally would, or use the `init` static convenience method.

```
// Create a new Money object representing $5 USD
$m = Money::init(500, 'USD');
$m = new Money(500, 'USD');
```

Values are stored as integers to avoid the problem of floating point errors. To access the value of the `Money` object you can simply request the `cents` property. To get the currency of the object you can request the `currency` property. This will return an instance of `Money\Curreny` that has a `__toString` method.

```
$m->cents; // 500
$m->currency; // United States Dollar
```

Equality is important to working with many different types of currency. You shouldn't be able to blindly add two different currencies without some kind of exchange process.

```
$m = Money::init(500, 'USD');

$m->isSameCurrency(Money::init(500, 'GBP')); // false
```

A [Value Object](http://en.wikipedia.org/wiki/Value_object) is an object that represents an entity whose equality isn't based on identity: i.e. two value objects are equal when they have the same value, not necessarily being the same object.

```
$one = Money::init(500, 'USD');
$two = Money::init(500, 'USD');
$three = Money::init(501, 'USD');

$one->equals($two); // true
$one->equals($three); // false
```

Inevitably you are going to need to add, subtract, multiply and divide values of money in your application.

```
$one = Money::init(500, 'USD');
$two = Money::init(500, 'USD');
$three = $one->add($two);
$three->cents // 1000
```

Again, you shouldn't be able to add to values of different currencies without some kind of exchange process.

```
$one = Money::init(500, 'USD');
$two = Money::init(500, 'GBP');

$three = $one->add($two); // Money\Exception\InvalidCurrencyException
```

License
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2014 Philip Brown

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

4400d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/59881cd39ca687db95393603c2ccf65001d8173ed4d22eb1461f6b9242d53558?d=identicon)[philipbrown](/maintainers/philipbrown)

---

Top Contributors

[![philipbrown](https://avatars.githubusercontent.com/u/1579059?v=4)](https://github.com/philipbrown "philipbrown (33 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[lyquidity/xbrl

Classes that implement the XBRL 2.1, XDT, Formulas, Generics and XFI specifications

482.8k](/packages/lyquidity-xbrl)

PHPackages © 2026

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