Skip to content

worksome/number

Repository files navigation

Number

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.