martinjoiner/ordinal-number
最新稳定版本:v1.0.0
Composer 安装命令:
composer require martinjoiner/ordinal-number
包简介
Converts numbers to a human readable ordinal form eg. 'first', 'second' or even 'Three thousand five hundred sixty first'
README 文档
README
A PHP package for converting numbers to a human readable sentence of it's ordinal form eg. 'first', 'second' or even 'Three thousand five hundred and sixty first'
Latest release supports numbers in the range 1 - 9999.
Installation
Recomended installation via Composer:
composer require martinjoiner/ordinal-number
See library page on Packagist https://packagist.org/packages/martinjoiner/ordinal-number
Usage example
// Tell our code to use the namespace use MartinJoiner\OrdinalNumber\OrdinalNumber; // The following line will output 'three hundred seventy eighth' print OrdinalNumber::convert( 378 ); // The following line will output 'three hundred and seventy eighth' print OrdinalNumber::convert( 378, true ); // The following line will output 'Three hundred and seventy eighth' (notice capitalised) print OrdinalNumber::convert( 378, true, true );
convert() method parameters
Required parameters
- num {integer} A number to be converted (in the range of 1 - 9999)
Optional parameters
- appendAnd {boolean} - Default: false - Places the word 'and' before the final 2 parts if number above 101 or higher (eg. One hundred and first). Added to support both American and European versions of English language.
- titleCase {boolean} - Default: false - Capitalises the first letter
To see some working examples simply run index.php
Testing
Tests are written in PHPUnit https://phpunit.de/
phpunit --bootstrap vendor/autoload.php tests/OrdinalNumberTest
统计信息
- 总下载量: 10.53k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-06