PHPackages                             philiprehberger/php-mask - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. philiprehberger/php-mask

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

philiprehberger/php-mask
========================

Mask sensitive data in strings, arrays, and objects for safe logging

v1.0.3(1mo ago)11[1 PRs](https://github.com/philiprehberger/php-mask/pulls)MITPHPPHP ^8.2CI passing

Since Mar 15Pushed 1mo agoCompare

[ Source](https://github.com/philiprehberger/php-mask)[ Packagist](https://packagist.org/packages/philiprehberger/php-mask)[ Docs](https://github.com/philiprehberger/php-mask)[ RSS](/packages/philiprehberger-php-mask/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

PHP Mask
========

[](#php-mask)

[![Tests](https://github.com/philiprehberger/php-mask/actions/workflows/tests.yml/badge.svg)](https://github.com/philiprehberger/php-mask/actions/workflows/tests.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/5767d1db3ac7a2f03c0c102c99c024d7a336ccb746e21ecb81da3dac65ddcd8b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068696c69707265686265726765722f7068702d6d61736b2e737667)](https://packagist.org/packages/philiprehberger/php-mask)[![License](https://camo.githubusercontent.com/d2234062658becd364a4d31f3fe48aa4bd51996d16b0fe0a05395b7ed49a07cf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7068696c69707265686265726765722f7068702d6d61736b)](LICENSE)

Mask sensitive data in strings, arrays, and objects for safe logging.

---

Requirements
------------

[](#requirements)

DependencyVersionPHP^8.2---

Installation
------------

[](#installation)

```
composer require philiprehberger/php-mask
```

---

Usage
-----

[](#usage)

### Email masking

[](#email-masking)

```
use PhilipRehberger\Mask\Mask;

Mask::email('john@example.com');
// "j***@e******.com"
```

### Phone masking

[](#phone-masking)

```
Mask::phone('+1-555-123-4567');
// "+1-555-***-4567"
```

### Credit card masking

[](#credit-card-masking)

```
Mask::creditCard('4111 1234 5678 1111');
// "4111 **** **** 1111"
```

### IP address masking

[](#ip-address-masking)

```
Mask::ip('192.168.1.100');
// "192.168.*.*"
```

### Generic string masking

[](#generic-string-masking)

```
Mask::string('SensitiveData');
// "Se*********ta"

Mask::string('SensitiveData', visibleStart: 3, visibleEnd: 3);
// "Sen*******ata"
```

### Array masking (deep)

[](#array-masking-deep)

```
$data = [
    'name' => 'John',
    'email' => 'john@example.com',
    'nested' => [
        'ssn' => '123-45-6789',
    ],
];

Mask::array($data, ['email', 'ssn']);
// ['name' => 'John', 'email' => 'jo************om', 'nested' => ['ssn' => '12*******89']]
```

### JSON masking

[](#json-masking)

```
$json = '{"name":"John","ssn":"123-45-6789"}';

Mask::json($json, ['ssn']);
// '{"name":"John","ssn":"12*******89"}'
```

### Custom configuration

[](#custom-configuration)

```
use PhilipRehberger\Mask\MaskConfig;

Mask::configure(new MaskConfig(
    maskChar: '#',
    preserveLength: false,
    visibleStart: 3,
    visibleEnd: 3,
));

Mask::string('SensitiveData');
// "Sen###ata"
```

---

API
---

[](#api)

MethodDescription`Mask::email(string $email): string`Mask an email address, preserving first char of local/domain and TLD`Mask::phone(string $phone): string`Mask a phone number, preserving country code and last 4 digits`Mask::creditCard(string $number): string`Mask a credit card, showing first 4 and last 4 digits`Mask::ip(string $ip): string`Mask an IP address, showing first two octets (v4) or groups (v6)`Mask::string(string $value, int $visibleStart = 2, int $visibleEnd = 2): string`Mask a generic string with configurable visible characters`Mask::array(array $data, array $keys): array`Deep-mask specified keys in an associative array`Mask::json(string $json, array $keys): string`Parse JSON, mask specified keys, re-encode`Mask::configure(MaskConfig $config): void`Set global masking configuration`Mask::resetConfig(): void`Reset configuration to defaults---

Development
-----------

[](#development)

```
composer install
vendor/bin/phpunit
vendor/bin/pint --test
vendor/bin/phpstan analyse
```

License
-------

[](#license)

MIT

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance89

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Every ~0 days

Total

4

Last Release

53d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cfd7d24cbbf32400fa13ce0bbe7a31edd2d66a6d4488eafdb3d64c5337bf0435?d=identicon)[philiprehberger](/maintainers/philiprehberger)

---

Top Contributors

[![philiprehberger](https://avatars.githubusercontent.com/u/8218077?v=4)](https://github.com/philiprehberger "philiprehberger (4 commits)")

---

Tags

loggingsanitizesensitiveprivacymaskredact

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/philiprehberger-php-mask/health.svg)

```
[![Health](https://phpackages.com/badges/philiprehberger-php-mask/health.svg)](https://phpackages.com/packages/philiprehberger-php-mask)
```

###  Alternatives

[monolog/monolog

Sends your logs to files, sockets, inboxes, databases and various web services

21.4k964.9M7.0k](/packages/monolog-monolog)[symfony/monolog-bundle

Symfony MonologBundle

2.9k249.1M1.5k](/packages/symfony-monolog-bundle)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k227.1M271](/packages/sentry-sentry)[sentry/sentry-laravel

Laravel SDK for Sentry (https://sentry.io)

1.3k114.3M154](/packages/sentry-sentry-laravel)[sentry/sentry-symfony

Symfony integration for Sentry (http://getsentry.com)

73761.4M65](/packages/sentry-sentry-symfony)

PHPackages © 2026

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