Oihana Php Masking

maskDocumentNode.php

Table of Contents

Functions

maskDocumentNode()  : array<string|int, mixed>
Walks an object: masks the matching leaves and descends into nested objects and arrays.

Functions

maskDocumentNode()

Walks an object: masks the matching leaves and descends into nested objects and arrays.

maskDocumentNode(array<string|int, mixed> $node, array<string|int, mixed> $maskings, string|null $exactPath, int $depth[, array<int, string> $protectedAttributes = [] ]) : array<string|int, mixed>

A leaf (scalar, null or a JSON array) is masked by the first matching rule (resolveMaskingRule()); an array with no matching rule is walked deeper (maskDocumentList()); a nested object recurses through this helper. The attributes named in $protectedAttributes are never masked at the top level ($depth === 0); the default is an empty list (nothing protected).

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

The object to walk.

$maskings : array<string|int, mixed>

The list of rules for this collection.

$exactPath : string|null

The dotted path of $node (null once an array has been crossed).

$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\maskDocumentNode;

$rules = [ [ 'path' => 'email' , 'type' => 'email' ] ] ;
maskDocumentNode( [ '_key' => 'a' , 'email' => 'real@example.com' ] , $rules , '' , 0 , [ '_key' ] ) ;
// [ '_key' => 'a' , 'email' => 'aZ12.bY34@cX56.invalid' ]
since
1.0.0
author

Marc Alcaraz

Return values
array<string|int, mixed>

The masked object.

On this page

Search results