mask-pii for PHP

Use mask-pii in PHP to mask email addresses and phone numbers when you write logs or process data.

Mask email addresses

Mask part of the email address before the @ and leave the domain visible.

Mask phone numbers

Mask the phone number and leave the last four digits visible.

Choose what to mask

Before you run it, choose whether to mask email addresses, phone numbers, or both. You can also pick the character to use.

Install it and try an example

Install the release we've checked from Packagist and load the PHP API. Run the example to turn on email and phone masking and see the result.

Installation

composer require finitefield-org/mask-pii

Try an example

example.php
<?php

use MaskPII\Masker;

$masker = (new Masker())
    ->maskEmails()
    ->maskPhones()
    ->withMaskChar("*");

echo $masker->process("Contact: alice@example.com or 090-1234-5678.");
// Contact: a****@example.com or ***-****-5678.
// Expected output: "Contact: a####@example.com or ###-####-5678."
More details

See the README for package details and API examples for this language.