承接 keios/moneyright 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

keios/moneyright

最新稳定版本:v1.0.9

Composer 安装命令:

composer require keios/moneyright

包简介

Precise, GAAP-compliant, database-friendly Money Value Object

README 文档

README

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

Arbitrary precision arithmetic-based Money value object. Drop-in replacement for Mathias Verraes' Money library (some use statement tweaking required). Follows GAAP suggestion to use 4 decimal places with rounding on 5th to minimize statistical influence of rounding errors.

Follows PSR-2 guidelines.

Project name is inspired by Kanye West's verse:

La la la la... wait till I get my money right!

As we all know money really should be right (and therefore not stored in floats!).

Requirements

PHP 5.4.0+ BCMath Arbitrary Precision Arithmetic PHP extension

Install

Via Composer

$ composer require keios/moneyright

Usage

$tenEuroNetPrice = Keios\MoneyRight\Money::EUR('10'); // Money::EUR(10000) integers as cents | Money::EUR(10.0) floats as literal amount

var_dump($tenEuroNetPrice->getAmount()); // int(1000) - cents
var_dump($tenEuroNetPrice->getAmountString()); // string(7) "10.0000" - literal amount in string with 4 decimal points precision

$vatTax = $tenEuroNetPrice->multiply('0.23'); // 23% VAT tax

var_dump(assert(!$vatTax->equals($tenEuroNetPrice))); // bool(true)
var_dump($vatTax->getAmountString()); // string(6) "2.3000"

$grossPrice = $tenEuroNetPrice->add($vatTax); // instances are immutable, so every operation returns new instance

var_dump($grossPrice->getAmountString()); // string(7) "12.3000"
var_dump($grossPrice->getAmount()); // int(1230) - cents

Testing

$ phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

统计信息

  • 总下载量: 55.21k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 20
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 20
  • Watchers: 3
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-08