worksome/number

A package for handling numbers in Laravel

Fund package maintenance!
worksome

v1.4.0 2024-04-01 11:32 UTC

This package is auto-updated.

Last update: 2024-12-09 11:17:20 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub PHPStan Action Status Total Downloads

A package for handling numbers in Laravel.

Installation

You can install the package via composer:

composer require worksome/number

Usage

use Worksome\Number\Number;

$number = Number::of(100);

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

echo $number; // 500

GraphQL

This package also provides GraphQL scalar types for the WebOnyx GraphQL PHP package / Lighthouse.

These should be auto-registered by Worksome\Number\Providers\NumberServiceProvider, however if you want to do this manually, they can be registered in the type registry using:

use Worksome\Number\GraphQL\Scalars\PercentageType;
use Worksome\Number\GraphQL\Scalars\StrictPercentageType;

// In Lighthouse (https://lighthouse-php.com)
$typeRegistry->register(new PercentageType());
$typeRegistry->register(new StrictPercentageType());

Testing

composer test

Updating snapshots

To update Pest snapshots, run the following:

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

Changelog

Please see GitHub Releases for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.