PHP code example of tobymaxham / array-faker-redactor

1. Go to this page and download the library: Download tobymaxham/array-faker-redactor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tobymaxham / array-faker-redactor example snippets


use TobyMaxham\ArrayFakerRedactor\ArrayFakerRedactor;

// An example array, maybe a request being made to/from an API application
$content = [
    'email'       => '[email protected]',
    'phone'       => '1234567',
    'password'    => 'secret123',
    'notes'       => 'this can be removed',
    'sample_data' => 'nothing else matters',
];

$redactor = (new ArrayFakerRedactor())->content($content)->keys(['email', 'password', 'notes', 'sample_data' => 'random'])->withFaker()->redact();

// $redactor will return something like:
[
    'email'       => '[email protected]',
    'phone'       => '1234567',
    'password'    => ']61i8~}DJB',
    'notes'       => '[REDACTED]',
    'sample_data' => 'e2k9aDUoeXRFQzhP',
];


$content = [
    'key' => 'some data',
];

$redactor = (new ArrayFakerRedactor())->content($content)->keys(['key' => 'myformatter'])
    ->withFaker()
    ->addFakerProvider(MyProvider::class)
    ->redact();