marcoconsiglio/faker-php-number-helpers

Adds a helper trait that makes it easier to generate random numbers using FakerPHP.

Maintainers

Package info

github.com/MarcoConsiglio/faker-php-number-helpers

pkg:composer/marcoconsiglio/faker-php-number-helpers

Statistics

Installs: 10

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

v2.0.0 2026-02-25 14:19 UTC

This package is auto-updated.

Last update: 2026-02-25 14:20:18 UTC


README

GitHub License Static Badge
Static Badge Static Badge Static Badge

faker-php-number-helpers

Adds a helper trait that makes it easier to generate random numbers using FakerPHP.

Installation

Use it as a production dependency

composer require marcoconsiglio/faker-php-number-helpers

or a development dependency

composer require --dev marcoconsiglio/faker-php-number-helpers

Usage

Add the trait to a TestCase class if you use this library in your tests project written in PHPUnit, otherwise add it wherever you need it.

<?php
namespace MyCompany\Project\Tests\Unit;

use PHPUnit\Framework\TestCase;
use MarcoConsiglio\FakerPhpNumberHelpers\WithFakerHelpers;

class MyUnitTestCase extends TestCase
{
    use WithFakerHelpers;

    ...
}

Examples

$number_1 = $this->negativeRandomFloatStrict(min: 10.0, max: 30.0, precision: 4); // (float) -14.5346
$number_2 = $this->nonZeroPositiveInteger(max: 10); // (int) 3

API Documentation

See more in the API Documentation for more helpers at ./docs/html/index.html.