sirmekus/otu 问题修复 & 功能扩展

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

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

sirmekus/otu

Composer 安装命令:

composer require sirmekus/otu

包简介

Otu is a PHP-based package that handles fine-formatting of string representation of (very) large numbers with their 'magnitude'. For instance, '50m' means 50000000. We can decide to write the entire 50000000 or just pass it to this package in the form of '50m' and have it take care of the presentati

README 文档

README

Otu is a PHP-based package that handles fine-formatting of string representation of (very) large numbers with their 'magnitude'. For instance, "50m" means 50000000. We can decide to write the entire 50000000 or just pass it to this package in the form of "50m" and have it take care of the presentation. It also works vice-versa. Walk with me.

As typical of my packages, each usage introduces you to a new word in Igbo language. You can be sure that "otu" is an Igbo word, and it means "one" which is actually a number anyway. You only need this "one" package, and without any dependencies, to improve productivity...#winks.

Installation

To get started all you need to do is:

composer require sirmekus/otu

That's all.

Please note that as at this time, we only support the following 'magnitudes' (it is case-insensitive): k: Thousand, m: Million, b: Billion, t: trillion

Supported "magnitude"/symbol Magnitude Example Figure
k Thousand "50k" 50000
m Million "40m" 40000000
b Billion "50b" 50000000000
t Trillion "1t" 1000000000000

Usage

Convert a string representation to a number

Example:

require_once 'vendor/autoload.php';

use Emmy\App\Assistant\Otu;

$converted = Otu::convertToNumber("89k");
//Output: 89000

$converted = Otu::convertToNumber("89.54k");
//Output: 89540

$converted = Otu::convertToNumber("89.5k");
//Output: 89500

$converted = Otu::convertToNumber("50.6M");
//Output: 50600000

//etc.

If you would like to present it in a more friendly human-readable format

$converted = Otu::format("50.6M");
//Output: 50,600,000.00

Abbreviate/represent a large number with its 'magnitude'

Example:

require_once 'vendor/autoload.php';

use Emmy\App\Assistant\Otu;

$converted = Otu::abbreviate(290450);
//Output: 290.5K

$converted = Otu::abbreviate(290450, round:false);
//Output (prevent rounding up "decimal" part): 290.4K

//Specify output in 2 'decimal' places
$converted = Otu::abbreviate(290456,2);
//Output: 290.46K

$converted = Otu::abbreviate(290450, useUnit:false);
//Output (full specification of the magnitude): 290.5 thousand

Meanwhile

You can connect with me on LinkedIn for insightful tips, and so we can grow our networks together.

Check our educational platform for High Schools: i-runs.

And follow me on Twitter.

We can also catch fun on Tiktok.

Join forces with me on Instagram

I encourage contribution even if it's in the documentation. Thank you, and I really hope you find this package helpful.

sirmekus/otu 适用场景与选型建议

sirmekus/otu 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 sirmekus/otu 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sirmekus/otu 我们能提供哪些服务?
定制开发 / 二次开发

基于 sirmekus/otu 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-28