Oihana Php Masking

maskRandom.php

Table of Contents

Functions

maskRandom()  : mixed
Replaces a leaf value with a random value of the **same kind**.

Functions

maskRandom()

Replaces a leaf value with a random value of the **same kind**.

maskRandom(mixed $value) : mixed

Implements the conventional random masker:

  • strings → a random string (see maskRandomString()) ;
  • integers → a random integer between -1000 and 1000 ;
  • floats → a random decimal between -1000 and 1000 ;
  • booleans → a random boolean ;
  • null → stays null.
Parameters
$value : mixed

The original value.

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

maskRandom( 'hello' ); // e.g. "x7Bqz"
maskRandom( 42 );      // e.g. -738
maskRandom( 2.34 );    // e.g. 91.7
maskRandom( true );    // e.g. false
maskRandom( null );    // null
since
1.0.0
author

Marc Alcaraz

Return values
mixed

The randomized value, type-preserved.

On this page

Search results