PHP code example of juststeveking / masking-engine
1. Go to this page and download the library: Download juststeveking/masking-engine 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/ */
final class Email extends StringMatcher
{
protected string $pattern = '/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/';
public function mask(): string
{
return (string) preg_replace_callback(
pattern: '/([^@]+)/',
callback: static fn(array $matches): string => str_repeat(
string: '*',
times: mb_strlen($matches[0]),
),
subject: $this->input,
limit: 1,
);
}
}
use JustSteveKing\Masking\Matchers\StringMatcher;
final class Dummy extends StringMatcher
{
public function mask(): string
{
return '<DUMMY VALUE>';
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.