Exemplo n.º 1
0
 /**
  * Testing that class iterates over given array
  */
 public function testGetMasked()
 {
     // Arrange
     $object = new \stdClass();
     $object->foo = 'bar';
     $object->bin = 'din';
     $object->arr = ['foo', 'faa', 'fee'];
     $inputArray = ['foo', $object, ['*****@*****.**', 'foo bar', [0 => 'bin zip', 1 => 'din zin', 2 => [0 => 'kas', 1 => 'bar']]], 'dot', ['4111 1111 1111 1111', '*****@*****.**', 'din@don'], 'tip', new Dummy\Stringable('foo string')];
     $expectedOutputArray = ['foo', $object, ['***@bar.com', 'foo bar', [0 => 'bin zip', 1 => 'din zin', 2 => [0 => 'kas', 1 => 'bar']]], 'dot', ['************1111', '***@foo.com', 'din@don'], 'tip', 'foo string'];
     $magoo = new Magoo();
     $magoo->pushEmailMask()->pushCreditCardMask();
     $magooArray = new MagooArray($magoo);
     // Act
     $outputArray = $magooArray->getMasked($inputArray);
     // Assert
     $this->assertSame($expectedOutputArray, $outputArray);
 }
Exemplo n.º 2
0
 /**
  * @param string $method
  * @param array $rawArguments
  *
  * @return array Masked arguments
  */
 private function getMaskedArguments($method, $rawArguments)
 {
     $arguments = $rawArguments;
     if (in_array($method, $this->logLevels)) {
         $maskedMessage = $this->maskManager->getMasked($arguments[0]);
         $arguments[0] = $maskedMessage;
         if (isset($arguments[1]) && !empty($arguments[1])) {
             $arguments[1] = $this->magooArray->getMasked($arguments[1]);
         }
         return $arguments;
     }
     $maskedMessage = $this->maskManager->getMasked($arguments[1]);
     $arguments[1] = $maskedMessage;
     if (isset($rawArguments[2]) && !empty($arguments[2])) {
         $arguments[2] = $this->magooArray->getMasked($arguments[2]);
     }
     return $arguments;
 }
Exemplo n.º 3
0
/**
 * 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\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] => 2016-08-21 11:44:33.000000
            [timezone_type] => 3
            [timezone] => UTC
        )