PHPackages                             olivernybroe/lighthouse-math-scalars - 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. olivernybroe/lighthouse-math-scalars

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

olivernybroe/lighthouse-math-scalars
====================================

A collection of custom scalar types for usage with https://github.com/webonyx/graphql-php

v0.2.2(5y ago)83.1kMITPHPPHP ^7.4|^8.0

Since Jan 9Pushed 5y ago2 watchersCompare

[ Source](https://github.com/olivernybroe/lighthouse-math-scalars)[ Packagist](https://packagist.org/packages/olivernybroe/lighthouse-math-scalars)[ RSS](/packages/olivernybroe-lighthouse-math-scalars/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

Lighthouse Math Scalars
=======================

[](#lighthouse-math-scalars)

A collection of custom scalar types for usage with [Lighthouse](https://lighthouse-php.com/).

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

[](#installation)

```
composer require olivernybroe/lighthouse-math-scalars
```

Usage
-----

[](#usage)

You can use the provided scalars just like any other type in your schema definition.
The scalars are automatically registered in Lighthouse.

```
type Battle {
  id: ID!
  attacker: User!
  defender: User!
  gold_stolen_ratio: Percentage!
  gold_stolen: BigInteger!
}
```

Scalars
-------

[](#scalars)

### BigInteger

[](#biginteger)

This scalar represents an integer with a size up to `2^63` whereas the built-in `Int` type is limited to `2^31`. The value is represented as an integer, not a string when returned.

### BigIntegerString

[](#bigintegerstring)

This scalar represents an integer with unlimited size. It is always returning the value as a string.
`BigInteger` will always return an integer, but is limited to `2^63`, however `BigIntegerString` is great for the cases where bigger values than that is required.

### BigIntegerDynamic

[](#bigintegerdynamic)

This scalar represents an integer which is bigger than the built-in `Int` type.
The built-in type is limited to `2^31`, however this type has unlimited size as it can use strings to represent it.

It will return the result from you query as an integer, as long as your integer is smaller than `2^63`. If your integer is bigger than that, it will be returned as a string instead.

### Percentage

[](#percentage)

Converts an integer value to a percentage.

Normally many of us stores percentages as an integer value and divide it by 100 to get it as a percentage.
This Scalar will do this conversion for you. If used as an input type, it will do the same conversion.

This scalar is useful for quickly identify for the users of your API, that the type is a percentage.

Casts
-----

[](#casts)

A set of casts which can be used in a Laravel model to cast attributes.

### BigInteger (`OliverNybroe\LighthouseMathScalars\Casts\BigInteger`)

[](#biginteger-olivernybroelighthousemathscalarscastsbiginteger)

When dealing with integers of bigger than `2^63`, a class is needed for doing all the mathematical calculations.
For doing that, this package relies on `\Brick\Math\BigInteger` underneath.
This cast will cast a value into the `BigInteger` class for you.

```
use OliverNybroe\LighthouseMathScalars\Casts\BigInteger as BigIntegerCast;
use Brick\Math\BigInteger;
use Illuminate\Foundation\Auth\User as Authenticatable;

/**
 * @property BigInteger $gold
 */
class User extends Authenticatable
{
    protected $casts = [
        'gold' => BigIntegerCast::class,
    ];
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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 ~7 days

Total

4

Last Release

1925d ago

PHP version history (2 changes)v0.1.0PHP ^7.4

v0.2.2PHP ^7.4|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5870441?v=4)[Oliver Nybroe](/maintainers/olivernybroe)[@olivernybroe](https://github.com/olivernybroe)

---

Top Contributors

[![olivernybroe](https://avatars.githubusercontent.com/u/5870441?v=4)](https://github.com/olivernybroe "olivernybroe (2 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/olivernybroe-lighthouse-math-scalars/health.svg)

```
[![Health](https://phpackages.com/badges/olivernybroe-lighthouse-math-scalars/health.svg)](https://phpackages.com/packages/olivernybroe-lighthouse-math-scalars)
```

###  Alternatives

[ramsey/uuid

A PHP library for generating and working with universally unique identifiers (UUIDs).

12.6k700.2M3.3k](/packages/ramsey-uuid)[brick/money

Money and currency library

1.9k37.9M102](/packages/brick-money)[pascaldevink/shortuuid

PHP 7.4+ library that generates concise, unambiguous, URL-safe UUIDs

5951.8M15](/packages/pascaldevink-shortuuid)[flow-php/etl

PHP ETL - Extract Transform Load - Abstraction

374468.4k51](/packages/flow-php-etl)[blair2004/nexopos

The Free Modern Point Of Sale System build with Laravel, TailwindCSS and Vue.js.

1.2k2.3k](/packages/blair2004-nexopos)[spomky-labs/cbor-php

CBOR Encoder/Decoder for PHP

576.4M30](/packages/spomky-labs-cbor-php)

PHPackages © 2026

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