Oihana Php Masking

maskDecimal.php

Table of Contents

Functions

maskDecimal()  : float
Replaces a value with a random decimal in `[lower, upper]`.

Functions

maskDecimal()

Replaces a value with a random decimal in `[lower, upper]`.

maskDecimal([mixed $value = null ][, float $lower = -1.0 ][, float $upper = 1.0 ][, int $scale = 2 ]) : float

Implements the conventional decimal masker: the value is replaced whatever its original type (string, boolean and null included), rounded to scale fraction digits. The bounds are inclusive; they are swapped if given in the wrong order.

Parameters
$value : mixed = null

The original value (ignored — replaced wholesale).

$lower : float = -1.0

Smallest value to return.

$upper : float = 1.0

Largest value to return.

$scale : int = 2

Maximum number of fraction digits.

Tags
throws
RandomException
example
use function oihana\masking\maskDecimal;

maskDecimal( 3.14 );                       // e.g. -0.42 (default -1..1, scale 2)
maskDecimal( 'x' , -0.3 , 0.3 , 2 );       // e.g. 0.17
since
1.0.0
author

Marc Alcaraz

Return values
float
On this page

Search results