README.md 972 Bytes
Newer Older
Mathias Verraes's avatar
Mathias Verraes committed
1
Money
Mathias Verraes's avatar
Mathias Verraes committed
2
=====
Mathias Verraes's avatar
Mathias Verraes committed
3

Mathias Verraes's avatar
Mathias Verraes committed
4
PHP 5.3+ library to make working with money safer, easier, and fun!
Mathias Verraes's avatar
Mathias Verraes committed
5

Mathias Verraes's avatar
Mathias Verraes committed
6
In short: You probably shouldn't represent monetary values by a float. Wherever 
Mathias Verraes's avatar
readme    
Mathias Verraes committed
7
8
9
10
11
12
13
14
15
16
17
you need to represent money, use this Money value object.

    <?php
	$fiveEur = Money::EUR(500);
	$tenEur = $fiveEur->add($fiveEur);
	
	list($part1, $part2, $part3) = $tenEur->allocate(array(1, 1, 1));
	assert($part1->equals(Money::EUR(334)));
	assert($part2->equals(Money::EUR(333)));
	assert($part3->equals(Money::EUR(333)));

Mathias Verraes's avatar
link    
Mathias Verraes committed
18
The documentation is available at http://money.readthedocs.org
Mathias Verraes's avatar
Mathias Verraes committed
19

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
[![Build Status](https://secure.travis-ci.org/mathiasverraes/money.png)](http://travis-ci.org/mathiasverraes/money)

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

Install the library using [composer][1]. Add the following to your `composer.json`:

```json
{
    "require": "mathiasverraes/money",
    "minimum-stability": "dev"    
}
```

Now run the `install` command.

```sh
$ composer.phar install
```

[1]: http://getcomposer.org/