PHPackages                             murilomagalhaes/masquerade - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. murilomagalhaes/masquerade

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

murilomagalhaes/masquerade
==========================

Masquearde is a library with a handful of methods to help you work with text manipulation.

1.3.3(3y ago)286MITPHPPHP ^7.4|8.\*

Since Jun 29Pushed 3y ago1 watchersCompare

[ Source](https://github.com/murilomagalhaes/masquerade)[ Packagist](https://packagist.org/packages/murilomagalhaes/masquerade)[ RSS](/packages/murilomagalhaes-masquerade/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)Dependencies (1)Versions (11)Used By (0)

🦝 Masquerade
============

[](#-masquerade)

 A PHP Text Manipulation Library

[![Static Analisys (PHP-STAN)](https://github.com/murilomagalhaes/masquerade/actions/workflows/static_analysis.yml/badge.svg)](https://github.com/murilomagalhaes/masquerade/actions/workflows/static_analysis.yml)

*Clique **[aqui](README_PT.md)** caso queira acessar a versão em **Português** deste arquivo!* 🇵🇹 🇧🇷

**Masquerade is a library with a handful of methods to help you work with text manipulation, so you (hopefully) don't need to google regex expressions for the thousandth time. It is intended to manipulate short strings such as form inputs and alike, even providing masking/formatting methods.**

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

[](#requirements)

- `PHP: ^7.4|8.*`
- `Composer`

Instalation
-----------

[](#instalation)

`composer require murilomagalhaes/masquerade`

Usage
-----

[](#usage)

- Once the package is installed, call it on your working file.

```
use Masquerade\Masquerade
```

- Use the `set()` method to start chaining filters, masks, and/or whatever other methods available

```
Masquerade::set("Phone: (Brazil) +55 61999995555'")
    ->only('numbers')
    ->mask('## (##) #####-####')
    ->getText(); // Returns: "55 (61) 99999-5555"
```

Examples
--------

[](#examples)

- Filtering

```
Masquerade::set("I got 99 problems but regex ain't one!")
    ->only('letters', 'whitespaces')
    ->getText(); // Returns: "I got problems but regex aint one!"

Masquerade::set("Phone: +55 00 99999-5555")
    ->only('numbers')
    ->getText(); // Returns "5500999995555"

Masquerade::set("Assistant (to the) regional manager")
    ->between('(', ')')
    ->getText(); // Returns "to the"

Masquerade::set("Hello, Universe")
    ->strip('Hello,')
    ->getText(); // Returns: "Universe"

Masquerade::set("I got 998 problems, but regex ain't one!")
    ->ignore('8')
    ->only('letters', 'whitespaces') // Note that the "numbers" type is missing, so all numbers should be filtered out.
    ->getText(), // Returns: "I got 8 problems but regex aint one!". The '8' was kept by the ignore() method

Masquerade::set("Hablo Español y Português")
    ->removeAccents()
    ->getText(); // Returns: "Hablo Espanol y Portugues"
```

- Masking | Formatting

```
Masquerade::set("Phone: (Brazil) +55 00999995555'")
    ->only('numbers')
    ->mask('## (##) #####-####')
    ->getText(); // Returns: "55 (00) 99999-5555"

Masquerade::set("00011122234")
    ->only('numbers')
    ->mask('###.###.###-##')
    ->getText(); // Returns: "000.111.222-34"
```

- Custom methods (Macros)

```
use Masquerade\StringHandler;

Masquerade::macro('maskAsPhone', function(StringHandler $handler){
    return $handler->only('numbers')->mask('(##) #####-####');
});

Masquerade::set('Number: 00999995555')
    ->maskAsPhone()
    ->getText(); // Returns: "(00) 99999-5555"
```

- Getters

```
$text = Masquerade::set('YMCA');

$text->mask('#-#-#-#');

$text->getText(); // Returns: "Y-M-C-A"
$text->getUnmaskedText(); // Returns: "YMCA"
```

Available Methods
-----------------

[](#available-methods)

Method SignatureDescription`set(string $text): Masquerade`Creates a new Masquerade instance, and defines the text string to be used by the chained methods.`only(...$filter_types): Masquerade`Keeps only the character types defined on the `$filter_types` parameter. Available types: `'letters'`, `'numbers'`, `'punctuation'` and `'whitespaces'`
 The following characters are understood as punctuation `, . : ; ? ¿ ! ¡ - ``ignore(... $character)`The defined characters won't be removed by the `only()`. Must be called BEFORE the `only()` method to take effect`strip(...$characters): Masquerade`Removes the defined characters from the text string`between(string $before, string $after): Masquerade`Keeps only the characters between the `$before` and `$after` parameters;`removeAccents(): Masquerade`Removes all character's accents.
(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|)`mask(string $pattern): Masquerade`Applies the defined pattern to the text string`format(string $pattern): Masquerade`Alias to the mask method`trim(): Masquerade`Removes trailing and multiple spaces/tabs from the text string
(Method always aplied on class \_\_toString() and getText() methods)`static::macro(string $name, callable $callback): void`Defines a macro/custom method`getText(): string`Returns the text string`getOriginalText(): string`Returns the text string on it's original state`getUnmaskedText(): string`Returns the text string before maskking

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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 ~27 days

Recently: every ~59 days

Total

10

Last Release

1214d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d814a88803d7ca852ecadd31f6cb8e8ce20d44574a6f2a60cd627a8610b10f6?d=identicon)[murilomagalhaes](/maintainers/murilomagalhaes)

---

Top Contributors

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

---

Tags

librarymaskphpregexstringstringlibraryregexMasking

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/murilomagalhaes-masquerade/health.svg)

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

###  Alternatives

[spatie/regex

A sane interface for php's built in preg\_\* functions

1.1k18.9M68](/packages/spatie-regex)[league/iso3166

ISO 3166-1 PHP Library

69837.6M135](/packages/league-iso3166)[hallindavid/manny

a package of manipulators that hopefully come in useful for those of us who always forget regex when we need it (manny is short for manipulation)

37106.7k3](/packages/hallindavid-manny)[jasonlam604/stringizer

Stringizer is a PHP string manipulation library with support for method chaining and multibyte handling

35110.5k1](/packages/jasonlam604-stringizer)

PHPackages © 2026

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