Thriving Thriving PHP PH
โ†‘ 82
short-number short-number/short-number

Lightweight package that shortens given number by taking digits and adding K, M, B or T after them. For example 1234 will be formatted to 1K and 20244023 to 20M. Package supports multiple languages

https://short-number.serhiicho.com/ โ†—
HEALTH 83 / Healthy
// solo builder// help wanted// legacy hero phpcomposer-packagedatetimepackagistpackagedockerpodman

// momentum

tracking since W49

// why it's here

  • Active: last commit today
  • Built almost entirely by one person
  • Has issues labelled for new contributors
  • Around since 2019 and still shipping

// how to help

// readme

Short Number

Lightweight package shortens given number to a short representation of it. For example 1234 will be formatted to 1k and 20244023 to 20m. Package supports multiple languages and can be easily extended with new languages.

Follow the full documentation for this package

Requirements

If you use Podman or Docker then requirements are already satisfied by the container image. Otherwise, make sure you have the following installed:

  • PHP 8.1 or higher
  • mbstring extension (used for the upperCase option)

Installation

composer require serhii/short-number

Usage

use Serhii\ShortNumber\Number;

Number::short(0);         // '0'
Number::short(999);       // '999'
Number::short(1234);      // '1k'
Number::short(5_935_235); // '5m'
Number::short(-1234);     // '-1k'

Numbers below 1000 are returned as is. Numbers are shortened up to 18 digits (999 quadrillion), anything larger throws Serhii\ShortNumber\Exceptions\LargeNumberException.

Languages

English is used by default. Set another language once before calling Number::short():

Read the full README on GitHub โ†—

Health score

Is the project alive and maintained right now? A 0โ€“100 pulse recomputed nightly from commit recency, rhythm, how fast issues close, and how quickly PRs get merged.

How it's calculated

Undervalued score

Activity relative to attention (stars + watchers). Above 50 means a lot of activity for a project its size. Recomputed nightly from commit velocity, contributor effort, issue resolution, fork utility, release cadence, and project maturity โ€” divided by a logarithmic reach factor.

How it's calculated

Tags

Tags are independent behavioral signals computed nightly. A project can hold multiple at once. They drive the home page sections.

How it's calculated