Oihana Php Masking

maskDocumentList.php

Table of Contents

Functions

maskDocumentList()  : array<string|int, mixed>
Applies the masking rules to every element of a JSON array (a PHP list).

Functions

maskDocumentList()

Applies the masking rules to every element of a JSON array (a PHP list).

maskDocumentList(array<string|int, mixed> $list, array<string|int, mixed> $maskings, int $depth[, array<int, string> $protectedAttributes = [] ]) : array<string|int, mixed>

Each element is handled on its own: a nested list recurses through this helper, a nested object is walked by maskDocumentNode(), and a bare scalar is left untouched (it is not a keyed attribute, so no path rule can target it directly — only the masker applied to the parent leaf reaches it). This mirrors the common "array elements are masked individually" rule.

Parameters
$list : array<string|int, mixed>

The list to walk.

$maskings : array<string|int, mixed>

The list of rules for this collection.

$depth : int

The current depth (protected attributes are top-level only).

$protectedAttributes : array<int, string> = []

Top-level attribute names never masked. Default: none.

Tags
throws
InvalidArgumentException

When a rule has no type, or an unknown masker.

RandomException
example
use function oihana\masking\maskDocumentList;

$rules = [ [ 'path' => '.name' , 'type' => 'xifyFront' , 'unmaskedLength' => 2 ] ] ;
maskDocumentList( [ [ 'name' => 'hugo' ] , 'egon' ] , $rules , 1 ) ;
// [ [ 'name' => 'xxgo' ] , 'egon' ]
since
1.0.0
author

Marc Alcaraz

Return values
array<string|int, mixed>

The masked list.

On this page

Search results