PHPackages                             yupmin/magoo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. yupmin/magoo

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

yupmin/magoo
============

PHP library to mask (redact) credit card numbers, emails and more.

3.0.0(3y ago)353.6k—3.4%MITPHPPHP ^7.4|^8.0|^8.1

Since Oct 18Pushed 1y agoCompare

[ Source](https://github.com/yupmin/magoo)[ Packagist](https://packagist.org/packages/yupmin/magoo)[ RSS](/packages/yupmin-magoo/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

Pachico\\Magoo
==============

[](#pachicomagoo)

[![Testing](https://github.com/yupmin/magoo/actions/workflows/testing.yml/badge.svg)](https://github.com/yupmin/magoo/actions/workflows/testing.yml)

original package [pachico/magoo](https://github.com/pachico/magoo) is abandoned. this is for php 7.4,8.0,8.1,8.2,8.3

Magoo is a PHP library that will mask sensitive data in strings. Built-in masks use regex to find credit card numbers, emails, etc. and will mask only those, leaving the rest of the strings intact. This might be useful, for instance, to log sensitive user input.

You can also mask strings that match your own regex or inject masking class as long as they implement a simple interface.

Multidimensional arrays can also be masked and use it can be used to mask [PSR-3](http://www.php-fig.org/psr/psr-3/) compliant logger libraries, such as Monolog.

Use the [issues](https://github.com/pachico/magoo/issues) page to request masks to implement.

Table of contents
-----------------

[](#table-of-contents)

- [Install](#install)
- [Usage](#usage)
- [Generic](#generic)
    - [Masks credit cards](#mask-credit-cards)
    - [Masks emails](#mask-emails)
    - [Mask by regex](#mask-by-regex)
    - [Reset](#reset)
    - [Custom masks](#custom-masks)
- [Mask arrays](#mask-arrays)
- [Mask PSR-3 logger](#mask-psr-3-logger)
- [Testing](#Testing)
- [Contributing](#contributing)
- [Security](#security)
- [Credits](#credits)
- [License](#license)
- [Help](#help)

Install
-------

[](#install)

Via Composer:

```
composer require pachico/magoo

```

Usage
-----

[](#usage)

### Generic

[](#generic)

This is a generic usage of the library.

```
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);

// 'My ***** is ***@trenneman.com and my credit card is ************6742'
```

### Mask credit cards

[](#mask-credit-cards)

Credit card mask accepts a custom replacement.

```
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.
```

### Mask emails

[](#mask-emails)

Email mask accepts as optional parameters the replacement for local and domain parts.

```
use Pachico\Magoo\Magoo;

$magoo = new Magoo();
$magoo->pushEmailMask('$', '*');

$mySensitiveString = 'My email is pachicodev@gmail.com but I need privacy.';

echo $magoo->getMasked($mySensitiveString);

// My email is $$$$$$$$$$@********* but I need privacy.
```

### Mask by regex

[](#mask-by-regex)

Regex mask will replace matches with strings that are long as each individual match. It requires a regex and accepts custom replacement.

```
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 __:__!
```

### Reset

[](#reset)

You might want to use the same instance of Magoo in your application but not the same masks everytime. You can reset all masks at any time by using the reset() method.

```
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.
```

### Custom masks

[](#custom-masks)

Additionally, you can add your own mask as long as it implements Maskinterface.

```
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.
```

Mask arrays
-----------

[](#mask-arrays)

Magoo includes a handy way to mask multidimensional arrays, which can be useful, for instance, for logger contexts.

```
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);
```

will output

```
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
        )

)
```

\##Mask PSR-3 logger You can also use Magoo as a wrapper for PSR-3 compliant loggers. In this example, we use Monolog.

```
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. [] []
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Mariano F.co Benítez Mulet](https://github.com/pachico/magoo)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Help
====

[](#help)

Please report any bug you might find and/or collaborate with your own masks.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1309d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/880878?v=4)[yun young-jin](/maintainers/yupmin)[@yupmin](https://github.com/yupmin)

---

Top Contributors

[![youngjin-yun-kurly](https://avatars.githubusercontent.com/u/50684655?v=4)](https://github.com/youngjin-yun-kurly "youngjin-yun-kurly (10 commits)")[![pachico](https://avatars.githubusercontent.com/u/2184438?v=4)](https://github.com/pachico "pachico (5 commits)")[![yupmin](https://avatars.githubusercontent.com/u/880878?v=4)](https://github.com/yupmin "yupmin (2 commits)")[![mariano-benitez-edo](https://avatars.githubusercontent.com/u/146073910?v=4)](https://github.com/mariano-benitez-edo "mariano-benitez-edo (1 commits)")

---

Tags

securityemailobfuscationcredit-cardsensitivemaskredactMaskingBleep out

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/yupmin-magoo/health.svg)

```
[![Health](https://phpackages.com/badges/yupmin-magoo/health.svg)](https://phpackages.com/packages/yupmin-magoo)
```

###  Alternatives

[zbateson/mail-mime-parser

MIME email message parser

54149.2M79](/packages/zbateson-mail-mime-parser)[fuko-php/masked

Masks sensitive data: replaces blacklisted elements with redacted values

14094.5k](/packages/fuko-php-masked)[martian/spammailchecker

A laravel package that protect users from entering non-existing/spam email addresses.

422.0k](/packages/martian-spammailchecker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
