PHP code example of coretsia / platform-redaction

1. Go to this page and download the library: Download coretsia/platform-redaction 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/ */

    

coretsia / platform-redaction example snippets


public function redactValue(
    string $value,
    RedactionKind $kind,
    RedactionContext $context,
): RedactedValue;

public function redactJsonLike(mixed $value, RedactionContext $context): mixed;

public function classify(string $key): ?RedactionKind;



declare(strict_types=1);

use Coretsia\Contracts\Security\RedactionContext;
use Coretsia\Contracts\Security\RedactionKind;
use Coretsia\Contracts\Security\RedactionMode;
use Coretsia\Contracts\Security\SensitiveDataRedactorInterface;

function redactKnownCredential(SensitiveDataRedactorInterface $redactor): array
{
    return $redactor->redactValue(
        'synthetic-credential',
        RedactionKind::Credential,
        new RedactionContext('cli.output'),
    )->toArray();
}

function redactDiagnostic(SensitiveDataRedactorInterface $redactor): mixed
{
    return $redactor->redactJsonLike(
        [
            'authorization' => 'synthetic-authorization-value',
            'details' => [
                'status' => 'ok',
                'token' => 'synthetic-token-value',
            ],
        ],
        new RedactionContext('cli.output', RedactionMode::Placeholder),
    );
}