Oihana Php Masking

maskValue.php

Table of Contents

Functions

maskValue()  : mixed
Applies a single masker to a value.

Functions

maskValue()

Applies a single masker to a value.

maskValue(string $type, mixed $value[, array<string|int, mixed> $params = [] ]) : mixed

This is the dispatcher in front of the per-type maskers (maskEmail(), maskXifyFront(), …). When the value is a JSON array (a PHP list), the masker is applied to each element individually — sub-arrays recurse, nested objects (associative arrays) are left untouched — mirroring the common "array elements are masked individually" rule. Scalars and null are masked directly.

Parameters
$type : string

The masker name (Masker).

$value : mixed

The value to mask.

$params : array<string|int, mixed> = []

The masker parameters (e.g. unmaskedLength, lower).

Tags
throws
InvalidArgumentException

When the masker name is unknown.

RandomException
example
use function oihana\masking\maskValue;

maskValue( 'email' , 'real@example.com' );             // "x7Bq.9aMz@Kp3R.invalid"
maskValue( 'xifyFront' , 'secret' , [ 'unmaskedLength' => 3 ] ); // "xxxret"
maskValue( 'random' , [ 1 , 'two' , true ] );          // [ -42, "x9Bz", false ]
since
1.0.0
author

Marc Alcaraz

Return values
mixed

The masked value.

On this page

Search results