PHPackages                             worksome/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. worksome/number

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

worksome/number
===============

A package for handling numbers in Laravel

v3.4.1(1mo ago)6376.1k↑39.7%1MITPHPPHP ^8.4CI passing

Since Apr 20Pushed 1mo ago11 watchersCompare

[ Source](https://github.com/worksome/number)[ Packagist](https://packagist.org/packages/worksome/number)[ Docs](https://github.com/worksome/number)[ GitHub Sponsors](https://github.com/worksome)[ RSS](/packages/worksome-number/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (16)Versions (31)Used By (0)

Number
======

[](#number)

[![Latest Version on Packagist](https://camo.githubusercontent.com/81e3d9cbc4f0a7c47d077cf10473ca76e4bcd00d1f99ab917489ea05670030ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776f726b736f6d652f6e756d6265722e7376673f7374796c653d666c61742d737175617265266c6162656c3d5061636b6167697374)](https://packagist.org/packages/worksome/number)[![GitHub Tests Action Status](https://camo.githubusercontent.com/0881dcb1f09bbbce622c3932a72dafd63f389a13517f22f11c288bac84240c94/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f776f726b736f6d652f6e756d6265722f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d5465737473267374796c653d666c61742d737175617265)](https://github.com/worksome/number/actions?query=workflow%3ATests)[![GitHub PHPStan Action Status](https://camo.githubusercontent.com/9ca35a09d0ae47b0cc042ccf5946cfd697abc6d418807251ac88aa1a86574ba2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f776f726b736f6d652f6e756d6265722f7374617469632e796d6c3f6272616e63683d6d61696e266c6162656c3d537461746963253230416e616c79736973267374796c653d666c61742d737175617265)](https://github.com/worksome/number/actions?query=workflow%3AStatic%20Analysis)[![Total Downloads](https://camo.githubusercontent.com/29a78b8ec4d9fdd89b40dc2366abb45b016df3bdc47dcf18e2a7858211ac4ead/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f776f726b736f6d652f6e756d6265722e7376673f7374796c653d666c61742d737175617265266c6162656c3d446f776e6c6f616473)](https://packagist.org/packages/worksome/number)

A package for handling numbers in Laravel.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require worksome/number
```

Usage
-----

[](#usage)

```
use Worksome\Number\Number;

$number = Number::of(100);

$number->mul(Number::of(5));

echo $number; // 500
```

Casting
-------

[](#casting)

This package allows you to easily cast attributes on your Eloquent models to number types.

```
use Illuminate\Database\Eloquent\Model;
use Worksome\Number\Casts\NumberFromCents;
use Worksome\Number\Casts\NumberFromDecimal;
use Worksome\Number\MonetaryAmount;
use Worksome\Number\Percentage;
use Worksome\Number\Number;

class Product extends Model
{
    protected $casts = [
        'a' => NumberFromCents::class,
        'b' => NumberFromDecimal::class,
        'c' => NumberFromDecimal::using(2, MonetaryAmount::class), // Cast to a specialised Number-class
        'd' => NumberFromDecimal::using(2, Percentage::class), // Cast to a specialised Number-class
        'e' => NumberFromDecimal::using(3), // Three decimal places - default is 2
    ];
}
```

Available Number Types
----------------------

[](#available-number-types)

The following Number types are available out of the box:

- `Number` - The base number type, with two decimal places. Can be configured to use a different default scale.
- `MonetaryAmount` - A number type for handling monetary amounts. Always uses two decimal places. Rounds automatically in all operations.
- `Percentage` - A number type for handling percentages. Makes it clear that the number represents a percentage, not an amount. Adds % on to string representations.

### GraphQL

[](#graphql)

This package also provides GraphQL scalar types for the [WebOnyx GraphQL PHP package](https://github.com/webonyx/graphql-php) / [Lighthouse](https://lighthouse-php.com).

These will be auto-registered for Lighthouse by [`Worksome\Number\Providers\NumberServiceProvider`](src/Providers/NumberServiceProvider.php). However, if you want to do this manually, they can be registered in the type registry using:

```
// In Lighthouse (https://lighthouse-php.com)
$typeRegistry->register(new \Worksome\Number\GraphQL\Scalars\DecimalTwoType());
$typeRegistry->register(new \Worksome\Number\GraphQL\Scalars\PercentageType());
$typeRegistry->register(new \Worksome\Number\GraphQL\Scalars\StrictPercentageType());
```

Testing
-------

[](#testing)

```
composer test
```

### Updating snapshots

[](#updating-snapshots)

To update Pest snapshots, run the following:

```
vendor/bin/pest -d --update-snapshots
```

Changelog
---------

[](#changelog)

Please see [GitHub Releases](https://github.com/worksome/number/releases) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Owen Voke](https://github.com/owenvoke)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

60

—

FairBetter than 99% of packages

Maintenance89

Actively maintained with recent releases

Popularity41

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 79.3% 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 ~62 days

Recently: every ~31 days

Total

24

Last Release

54d ago

Major Versions

v0.2.0 → v1.0.02022-08-30

v1.4.0 → v2.0.02025-02-14

v2.2.1 → v3.0.02025-11-21

PHP version history (4 changes)v0.1.0PHP ^8.0

v1.1.2PHP ^8.2

v2.2.0PHP ^8.3

v3.0.0PHP ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1899334?v=4)[Owen Voke](/maintainers/owenvoke)[@owenvoke](https://github.com/owenvoke)

---

Top Contributors

[![owenvoke](https://avatars.githubusercontent.com/u/1899334?v=4)](https://github.com/owenvoke "owenvoke (111 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (11 commits)")[![alberthaff](https://avatars.githubusercontent.com/u/3864165?v=4)](https://github.com/alberthaff "alberthaff (7 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")[![lukeraymonddowning](https://avatars.githubusercontent.com/u/12202279?v=4)](https://github.com/lukeraymonddowning "lukeraymonddowning (4 commits)")[![olivernybroe](https://avatars.githubusercontent.com/u/5870441?v=4)](https://github.com/olivernybroe "olivernybroe (1 commits)")[![vsg24](https://avatars.githubusercontent.com/u/7500363?v=4)](https://github.com/vsg24 "vsg24 (1 commits)")

---

Tags

laravelnumberworksome

###  Code Quality

TestsPest

Static AnalysisPHPStan

### Embed Badge

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

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

###  Alternatives

[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[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)[worksome/feature-flags

A package to manage feature flags in your application

11506.3k](/packages/worksome-feature-flags)[hnhdigital-os/laravel-number-converter

Number to word, roman, ordinal converter

20163.3k2](/packages/hnhdigital-os-laravel-number-converter)

PHPackages © 2026

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