marcoconsiglio / faker-php-number-helpers
Adds a helper trait that makes it easier to generate random numbers using FakerPHP.
Package info
github.com/MarcoConsiglio/faker-php-number-helpers
pkg:composer/marcoconsiglio/faker-php-number-helpers
v2.0.0
2026-02-25 14:19 UTC
Requires
- fakerphp/faker: ^1.24
Requires (Dev)
- phpunit/phpunit: ^13.0
README
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.