PHPackages                             flextype-components/number - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. flextype-components/number

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

flextype-components/number
==========================

The Number Component contains methods that can be useful when working with numbers.

v1.1.1(5y ago)05.5k1MITPHPPHP ^7.1.3

Since Apr 19Pushed 5y ago1 watchersCompare

[ Source](https://github.com/flextype-components/number)[ Packagist](https://packagist.org/packages/flextype-components/number)[ Docs](https://github.com/flextype-components/curl)[ RSS](/packages/flextype-components-number/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (1)

Number Component
================

[](#number-component)

[![version](https://camo.githubusercontent.com/98461fd39a6ad414ce4f6539d637885f04a4138fba65a452d579c06fa284c719/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d312e312e312d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265 "Version")](https://camo.githubusercontent.com/98461fd39a6ad414ce4f6539d637885f04a4138fba65a452d579c06fa284c719/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d312e312e312d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)[![MIT License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/flextype-components/number/blob/master/LICENSE)

The Number Component contains methods that can be useful when working with numbers.

### Installation

[](#installation)

```
composer require flextype-components/number

```

### Usage

[](#usage)

```
use Flextype\Component\Number\Number;
```

Converts a number of bytes to a human readable number by taking the number of that unit that the bytes will go into it.

```
echo Num::format_bytes('204800');     // 200 kB
echo Num::format_bytes('214901', 1);  // 209.9 kB
echo Num::format_bytes('2249010', 1); // 2.1 MB
echo Num::format_bytes('badbyteshere'); // false
```

Converts a file size number to a byte value.

```
echo Number::convertToBytes('200K');  // 204800
echo Number::convertToBytes('5MiB');  // 5242880
echo Number::convertToBytes('2.5GB'); // 2684354560
```

Converts a number into a more readable human-type number.

```
echo Number::quantity(7000); // 7K
echo Number::quantity(7500); // 8K
echo Number::quantity(7500, 1); // 7.5K
```

Checks if the value is between the minimum and maximum (min &amp; max included).

```
if (Number::between(2, 10, 5)) {
    // do something...
}
```

Checks the value for an even number.

```
if (Number::even(2)) {
    // do something...
}
```

Checks if the value is greather than a given minimum.

```
if (Number::greaterThan(2, 10)) {
     // do something...
}
```

Checks if the value is smaller than a given maximum.

```
if (Number::smallerThan(2, 10)) {
     // do something...
}
```

Checks if the value is not greater than or equal a given maximum.

```
if (Number::maximum(2, 10)) {
     // do something...
}
```

Checks if the value is greater than or equal to a given minimum.

```
if (Number::minimum(2, 10)) {
     // do something...
}
```

Checks the value for an odd number.

```
if (Number::odd(2)) {
     // do something...
}
```

Transforms a number by masking characters in a specified mask format, and ignoring characters that should be injected into the string without matching a character from the original string (defaults to space).

```
// ************5678
echo Number::maskString('1234567812345678', '************0000');

// **** **** **** 5678
echo Number::maskString('1234567812345678', '**** **** **** 0000');

// **** - **** - **** - 5678
echo Number::maskString('1234567812345678', '**** - **** - **** - 0000', ' -');
```

Formats a number by injecting non-numeric characters in a specified format into the string in the positions they appear in the format.

```
// (123) 456-7890
echo Number::format('1234567890', '(000) 000-0000');

// 123.456.7890
echo Number::format('1234567890', '000.000.0000');
```

Formats a phone number.

```
// (061) 234 5678
echo Number::formatPhone('0612345678');

// (06) 123 456 78
echo Number::formatPhone('0612345678', '(00) 000 000 00');
```

Formats (masks) a credit card.

```
// **** **** **** 2938
echo Number::maskСreditСard('1234263583742938');

// 1234 **** **** ****
echo Number::maskСreditСard('1234123412341234', '0000 **** **** ****');
```

Formats a credit card expiration string. Expects 4-digit string (MMYY).

```
// 12-34
echo Number::formatExp('1234');

// 12/34
echo Number::formatExp('1234', '00/00');
```

License
-------

[](#license)

See [LICENSE](https://github.com/flextype-components/number/blob/master/LICENSE)

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~418 days

Total

3

Last Release

2111d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/477114?v=4)[Sergey Romanenko](/maintainers/Awilum)[@Awilum](https://github.com/Awilum)

---

Top Contributors

[![Awilum](https://avatars.githubusercontent.com/u/477114?v=4)](https://github.com/Awilum "Awilum (5 commits)")

---

Tags

number

### Embed Badge

![Health badge](/badges/flextype-components-number/health.svg)

```
[![Health](https://phpackages.com/badges/flextype-components-number/health.svg)](https://phpackages.com/packages/flextype-components-number)
```

###  Alternatives

[kwn/number-to-words

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

4235.0M21](/packages/kwn-number-to-words)[php-decimal/php-decimal

Correctly-rounded arbitrary precision decimal floating point

781.0M9](/packages/php-decimal-php-decimal)[wilon/php-number2chinese

PHP数字转为汉字描述、人民币大写方法。

14632.0k1](/packages/wilon-php-number2chinese)[hekmatinasser/notowo

This Package helps developers change number to word for all language on Laravel freamwork PHP

32510.4k2](/packages/hekmatinasser-notowo)[hallindavid/manny

a package of manipulators that hopefully come in useful for those of us who always forget regex when we need it (manny is short for manipulation)

38103.3k2](/packages/hallindavid-manny)[data-values/number

Numerical value objects, parsers and formatters

18303.0k14](/packages/data-values-number)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
