roslov/log-obfuscator

Log Obfuscator

1.0.2 2024-03-25 12:53 UTC

This package is auto-updated.

Last update: 2024-04-25 13:38:40 UTC


README

This package hides sensitive information in text (usually, in logs).

Requirements

  • PHP 7.4 or higher.

Installation

The package could be installed with composer:

composer require roslov/log-obfuscator

General usage

#!/usr/bin/env php
<?php

declare(strict_types=1);

use Roslov\LogObfuscator\LogObfuscator;

require_once __DIR__ . '/vendor/autoload.php';

$obfuscator = new LogObfuscator();

$json = <<<'JSON'
    {
        "username": "user",
        "password": "123456789"
    }
    JSON;

echo $obfuscator->obfuscate($json);

This will return:

{
    "username": "user",
    "password": "×××××"
}

Testing

Unit testing

The package is tested with PHPUnit. To run tests:

./vendor/bin/phpunit

Code style analysis

The code style is analyzed with PHP_CodeSniffer and PSR-12 Ext coding standard. To run code style analysis:

./vendor/bin/phpcs --extensions=php --colors --standard=PSR12Ext --ignore=vendor/* -p -s .