Ejemplo n.º 1
0
 /**
  * Test that getMaskManager returns Magoo or compatible
  */
 public function testGetMaskManager()
 {
     // Arrange
     $magoo = new Magoo();
     $magoo->pushEmailMask()->pushCreditCardMask();
     $magooArray = new MagooArray($magoo);
     // Act
     // Assert
     $this->assertSame($magoo, $magooArray->getMaskManager());
 }
Ejemplo n.º 2
0
<?php

/**
 * This file is part of Pachico/Magoo. (https://github.com/pachico/magoo)
 *
 * @link https://github.com/pachico/magoo for the canonical source repository
 * @copyright Copyright (c) 2015-2016 Mariano F.co Benítez Mulet. (https://github.com/pachico/)
 * @license https://raw.githubusercontent.com/pachico/magoo/master/LICENSE.md MIT
 */
require __DIR__ . '/../vendor/autoload.php';
use Pachico\Magoo\Magoo;
$magoo = new Magoo();
$magoo->pushEmailMask('$', '*');
$mySensitiveString = 'My email is pachicodev@gmail.com but I need privacy.';
echo $magoo->getMasked($mySensitiveString . PHP_EOL);
// My email is $$$$$$$$$$@********* but I need privacy.
Ejemplo n.º 3
0
<?php

/**
 * This file is part of Pachico/Magoo. (https://github.com/pachico/magoo)
 *
 * @link https://github.com/pachico/magoo for the canonical source repository
 * @copyright Copyright (c) 2015-2016 Mariano F.co Benítez Mulet. (https://github.com/pachico/)
 * @license https://raw.githubusercontent.com/pachico/magoo/master/LICENSE.md MIT
 */
require __DIR__ . '/../vendor/autoload.php';
use Pachico\Magoo\Magoo;
$magoo = new Magoo();
$magoo->pushCreditCardMask()->pushEmailMask()->pushByRegexMask('/(email)+/m');
$mySensitiveString = 'My email is roy@trenneman.com and my credit card is 6011792594656742';
echo $magoo->getMasked($mySensitiveString . PHP_EOL);
// 'My ***** is ***@trenneman.com and my credit card is ************6742'
Ejemplo n.º 4
0
<?php

/**
 * This file is part of Pachico/Magoo. (https://github.com/pachico/magoo)
 *
 * @link https://github.com/pachico/magoo for the canonical source repository
 * @copyright Copyright (c) 2015-2016 Mariano F.co Benítez Mulet. (https://github.com/pachico/)
 * @license https://raw.githubusercontent.com/pachico/magoo/master/LICENSE.md MIT
 */
require __DIR__ . '/../vendor/autoload.php';
use Pachico\Magoo\Magoo;
$magoo = new Magoo();
$magoo->pushCreditCardMask('·');
$mySensitiveString = 'This is my credit card number: 4111 1111 1111 1111.';
echo $magoo->getMasked($mySensitiveString . PHP_EOL);
// This is my credit card number: ······1111.
Ejemplo n.º 5
0
<?php

/**
 * This file is part of Pachico/Magoo. (https://github.com/pachico/magoo)
 *
 * @link https://github.com/pachico/magoo for the canonical source repository
 * @copyright Copyright (c) 2015-2016 Mariano F.co Benítez Mulet. (https://github.com/pachico/)
 * @license https://raw.githubusercontent.com/pachico/magoo/master/LICENSE.md MIT
 */
require __DIR__ . '/../vendor/autoload.php';
use Pachico\Magoo\Magoo;
use Pachico\Magoo\MagooLogger;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
$magoo = new Magoo();
$magoo->pushByRegexMask('(foo)', 'bar');
$logger = new Logger('app');
$logger->pushHandler(new StreamHandler('php://stdout'));
$magooLogger = new MagooLogger($logger, $magoo);
$mySensitiveString = 'It is time to go to the foo.';
$magooLogger->warning($mySensitiveString, ['first' => 'It is time to go to the foo.', 'second' => 'Nothing like Living in foocelona']);
$magooLogger->log('debug', $mySensitiveString);
//[2016-09-30 13:01:28] app.WARNING: It is time to go to the bar. {"first":"It is time to go to the bar.","second":"Nothing like Living in barcelona"} []
//[2016-09-30 13:01:28] app.DEBUG: It is time to go to the bar. ["It is time to go to the bar."] []
Ejemplo n.º 6
0
 /**
  * Testing Magoo
  */
 public function testGetMaskManager()
 {
     // Arrange
     $magoo = new Magoo();
     $magoo->pushEmailMask();
     $logger = new Logger('app');
     $handler = new TestHandler();
     $logger->pushHandler($handler);
     $magooLogger = new MagooLogger($logger, $magoo);
     // Act
     // Assert
     $this->assertSame($magoo, $magooLogger->getMaskManager());
 }
Ejemplo n.º 7
0
<?php

/**
 * This file is part of Pachico/Magoo. (https://github.com/pachico/magoo)
 *
 * @link https://github.com/pachico/magoo for the canonical source repository
 * @copyright Copyright (c) 2015-2016 Mariano F.co Benítez Mulet. (https://github.com/pachico/)
 * @license https://raw.githubusercontent.com/pachico/magoo/master/LICENSE.md MIT
 */
require __DIR__ . '/../vendor/autoload.php';
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 . PHP_EOL);
// My CC is ************____ and my telephone number is ___.___.___.
$magoo->reset();
echo $magoo->getMasked($mySensitiveString . PHP_EOL);
// My CC is 4111 1111 1111 1111 and my telephone number is 639.639.639.
Ejemplo n.º 8
0
<?php

/**
 * This file is part of Pachico/Magoo. (https://github.com/pachico/magoo)
 *
 * @link https://github.com/pachico/magoo for the canonical source repository
 * @copyright Copyright (c) 2015-2016 Mariano F.co Benítez Mulet. (https://github.com/pachico/)
 * @license https://raw.githubusercontent.com/pachico/magoo/master/LICENSE.md MIT
 */
require __DIR__ . '/../vendor/autoload.php';
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.' . PHP_EOL;
echo $magoo->getMasked($mySensitiveString);
// It is time to go to the bar.
Ejemplo n.º 9
0
<?php

/**
 * This file is part of Pachico/Magoo. (https://github.com/pachico/magoo)
 *
 * @link https://github.com/pachico/magoo for the canonical source repository
 * @copyright Copyright (c) 2015-2016 Mariano F.co Benítez Mulet. (https://github.com/pachico/)
 * @license https://raw.githubusercontent.com/pachico/magoo/master/LICENSE.md MIT
 */
require __DIR__ . '/../vendor/autoload.php';
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 . PHP_EOL);
// My telephone number is ___.___.___. Call me at __:__!