komakino/roman-numerals

v1.0.3 2019-09-05 21:38 UTC

This package is not auto-updated.

Last update: 2024-09-18 23:47:44 UTC


README

用于整数和罗马数字之间转换的Composer包。

处理从0到3999的数字。对于0,使用字符串'nulla'。

安装

要将此包作为依赖项添加到您的项目中,只需将komakino/roman-numerals依赖项添加到您的项目中的composer.json文件中即可。

    {
        "require": {
            "komakino/roman-numerals": "*"
        }
    }

用法

use Komakino\RomanNumerals\RomanNumerals;

$roman   = RomanNumerals::to(2016);       // returns 'MMXVI'
$integer = RomanNumerals::from('DCLXVI'); // returns 666

公共静态方法

  • string to($integer)

    • 将整数转换为罗马数字
    • 如果整数是负数,将抛出OutOfBoundsException
    • 如果整数大于或等于4000,将抛出OutOfBoundsException
  • string from($string)

    • 将罗马数字转换为整数
    • 如果字符串包含非法字符,将抛出InvalidArgumentException

变更日志

v1.0.0

  • 首次公开发布

v1.0.1

  • 新增README文件

v1.0.2

  • 将许可证和作者添加到composer.json

v1.0.3

  • 添加LICENSE文件