1. Go to this page and download the library: Download yupmin/magoo 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/ */
yupmin / magoo example snippets
use Pachico\Magoo\Magoo;
$magoo = new Magoo();
$magoo->pushCreditCardMask()
->pushEmailMask()
->pushByRegexMask('/(email)+/m');
$mySensitiveString = 'My email is [email protected] and my credit card is 6011792594656742';
echo $magoo->getMasked($mySensitiveString);
// 'My ***** is ***@trenneman.com and my credit card is ************6742'
use Pachico\Magoo\Magoo;
$magoo = new Magoo();
$magoo->pushCreditCardMask('·');
$mySensitiveString = 'This is my credit card number: 4111 1111 1111 1111.';
echo $magoo->getMasked($mySensitiveString);
// This is my credit card number: ······1111.
use Pachico\Magoo\Magoo;
$magoo = new Magoo();
$magoo->pushEmailMask('$', '*');
$mySensitiveString = 'My email is [email protected] but I need privacy.';
echo $magoo->getMasked($mySensitiveString);
// My email is $$$$$$$$$$@********* but I need privacy.
use Pachico\Magoo\Magoo;
$magoo = new Magoo();
$magoo->pushByRegexMask('(\d+)', '_');
$mySensitiveString = 'My telephone number is 639.639.639. Call me at 19:00!';
echo $magoo->getMasked($mySensitiveString);
// My telephone number is ___.___.___. Call me at __:__!
use Pachico\Magoo\Magoo;
$magoo = new Magoo();
$magoo->pushCreditCardMask()->pushByRegexMask('(\d+)', '_');
$mySensitiveString = 'My CC is 4111 1111 1111 1111 and my telephone number is 639.639.639.';
echo $magoo->getMasked($mySensitiveString);
// My CC is ************____ and my telephone number is ___.___.___.
$magoo->reset();
echo $magoo->getMasked($mySensitiveString);
// My CC is 4111 1111 1111 1111 and my telephone number is 639.639.639.
use Pachico\Magoo\Magoo;
class FooMask implements \Pachico\Magoo\Mask\MaskInterface
{
protected $replacement = '*';
public function __construct(array $params = [])
{
if (isset($params['replacement']) && is_string($params['replacement'])) {
$this->replacement = $params['replacement'];
}
}
public function mask($string)
{
return str_replace('foo', $this->replacement, $string);
}
}
$magoo = new Magoo();
$customMask = new FooMask(['replacement' => 'bar']);
$magoo->pushMask($customMask);
$mySensitiveString = 'It is time to go to the foo.';
echo $magoo->getMasked($mySensitiveString);
// It is time to go to the bar.
use Pachico\Magoo\Magoo;
use Pachico\Magoo\MagooArray;
$magoo =new Magoo();
$magoo->pushByRegexMask('(foo)', 'bar');
$magooArray = new MagooArray($magoo);
$mySensitiveArray = [
'It is time to go to the foo.',
[
'It is never too late to go the foo.'
],
new DateTime()
];
$magooArray->getMasked($mySensitiveArray);
Array
(
[0] => It is time to go to the bar.
[1] => Array
(
[0] => It is never too late to go the bar.
)
[2] => DateTime Object
(
[date] => 2020-08-21 11:44:33.000000
[timezone_type] => 3
[timezone] => UTC
)
)
use Pachico\Magoo\Magoo;
use Pachico\Magoo\MagooLogger;
use Monolog\Logger;
use Monolog\Handler\ErrorLogHandler;
$magoo = new Magoo();
$magoo->pushByRegexMask('(foo)', 'bar');
$logger = new Logger('app');
$handler = new ErrorLogHandler();
$logger->pushHandler($handler);
$magooLogger = new MagooLogger($logger, $magoo);
$mySensitiveString = 'It is time to go to the foo.';
$magooLogger->warning($mySensitiveString);
// [2020-08-20 15:54:34] app.WARNING: It is time to go to the bar. [] []
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.