tentwofour/formatter 问题修复 & 功能扩展

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

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

tentwofour/formatter

最新稳定版本:1.1.3

Composer 安装命令:

composer require tentwofour/formatter

包简介

Provides formatters for phone numbers, postal codes, etc.

README 文档

README

MoneyFormatter

Formats from cents => dollars, and vice-versa. Useful for database storage of monetary values, without needing a decimal column.

PHP's Type Juggling deals with string arguments, which may lead to unexpected results.

MoneyFormatter::dollarsToCents(12.00);
// => 1200

MoneyFormatter::dollarsToCents(1200);
// => 12.00

PhoneNumberFormatter

Formats a phone number to a flattened string (eg. no separators of any kind), and back to a human-readable style again.

Current human-readable formats are N/A style (+%d (%d) %d-%d).

Useful for normalizing database stored values and allowing application-varied formatting.

$f = new PhoneNumberFormatter('+14239170989');

$formatted = $f->format()
// => +1 (423) 917-0989

$f->setPhoneNumber($formatted);
$reverse = $f->reverseFormat();
// => +14239170989

PostalCodeFormatter

Formats a postal code to a flattened representation, and back again. Supports US & Canadian postal codes.

Useful for normalizing database stored values and allowing application-varied formatting.

$f = new PostalCodeFormatter('H0H 0H0');

$formatted = $f->format()
// => h0h0h0 

$f->setPostalCode($formatted);
$reverse = $f->reverseFormat();
// => H0H 0H0

统计信息

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

GitHub 信息

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

其他信息

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