Git Product home page Git Product logo

money's Introduction

Money

Latest Version Build Status Code Coverage Quality Score Total Downloads

Email

Money PHP

PHP 5.5+ library to make working with money safer, easier, and fun!

"If I had a dime for every time I've seen someone use FLOAT to store currency, I'd have $999.997634" -- Bill Karwin

In short: You shouldn't represent monetary values by a float. Wherever you need to represent money, use this Money value object. Since version 3.0 this library uses strings internally in order to support unlimited integers.

<?php

use Money\Money;

$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)));

The documentation is available at http://moneyphp.org

Install

Via Composer

$ composer require moneyphp/money

Features

  • JSON Serialization
  • Big integer support utilizing different, transparent calculation logic upon availability (bcmath, gmp, plain php)
  • Money formatting (including intl formatter)
  • Currency repositories (ISO currencies included)
  • Money exchange (including Swap implementation)

Documentation

Please see the official documentation.

Testing

We try to follow BDD and TDD, as such we use both phpspec and phpunit to test this library.

$ composer test

Contributing

We would love to see you helping us to make this library better and better. Please keep in mind we do not use suffixes and prefixes in class names, so not CurrenciesInterface, but Currencies. Other than that, Style CI will help you using the same code style as we are using. Please provide tests when creating a PR and clear descriptions of bugs when filing issues.

Security

If you discover any security related issues, please contact us at [email protected].

License

The MIT License (MIT). Please see License File for more information.

Acknowledgements

This library is heavily inspired by Martin Fowler's Money pattern. A special remark goes to Mathias Verraes, without his contributions, in code and via his blog, this library would not be where it stands now.

money's People

Contributors

asm89 avatar bendavies avatar camspiers avatar elazer avatar elstamey avatar frederikbosch avatar h4cc avatar isabellejaffrezic avatar jongotlin avatar lucasmichot avatar marijn avatar mathiasverraes avatar michaelgooden avatar pamil avatar piotrantosik avatar rgeraads avatar robinmalfait avatar sagikazarmark avatar sahildua2305 avatar sharom avatar teohhanhui avatar thewilkybarkid avatar umpirsky avatar unnawut avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.