lukaszwit/currency 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

lukaszwit/currency

最新稳定版本:0.3.0

Composer 安装命令:

composer require lukaszwit/currency

包简介

Currency handling with float operations safe

README 文档

README

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

Currency package introduces strictly typed and precision safe containers to work with currencies. Currency keeps internally amount as string (the only safe representation of floating point number in PHP). It ensures that once any amount in given currency is defined you cannot change it's type and you can type hint your methods to use nay currency or one exact currency. Internally this lib uses SplType extension and SplString class. Keeping amounts in string prevents from floats problems and lets you use high precision libraries like bcMath to process arithmetic operations.

See how floats work in PHP - http://php.net/manual/en/language.types.float.php

See what happen when you relies on float precision - http://stackoverflow.com/questions/3726721/php-math-precision

This package also supports well-known cryptocurrencies listed in wikipedia - http://en.wikipedia.org/wiki/Cryptocurrency#List_of_cryptocurrencies

Install

First you need to install SPL_Types - PECL extension:

$ pecl install SPL_Types

If SPL_Types is installed you can now install currency package via Composer:

$ composer require lukaszwit/currency

Usage

<?php
use Currency\Eur;

$eur = new Eur;
$eur = '10'; // this is OK

$eur = 10; // but this emits UnexpectedValueException

Type hinting

<?php
use Currency\Usd;
use Currency\AbstractCurrency as Currency;

class Example
{
    public function workWithCurrency(Currency $c)
    {

    }

    public function workOnlyWithUsd(Usd $usd)
    {

    }
}

see more examples in examples directory - https://github.com/lukaszwit/currency/tree/master/examples.

Testing

$ phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

Bitdeli Badge

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-11-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固