PHPackages                             hallindavid/manny - 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. hallindavid/manny

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

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)

v1.02(3y ago)38103.3k—6.8%5[1 issues](https://github.com/hallindavid/manny/issues)1MITPHPPHP ^7.2|^8CI failing

Since Mar 30Pushed 3mo ago3 watchersCompare

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

READMEChangelog (3)Dependencies (1)Versions (11)Used By (1)

[![hallindavid](https://camo.githubusercontent.com/b7133d2ef1c0e38ac6a3165771d0b428dc602bcb64fdda3d8ba21edc4ae8f5e6/68747470733a2f2f636972636c6563692e636f6d2f67682f68616c6c696e64617669642f6d616e6e792e7376673f7374796c653d737667)](https://camo.githubusercontent.com/b7133d2ef1c0e38ac6a3165771d0b428dc602bcb64fdda3d8ba21edc4ae8f5e6/68747470733a2f2f636972636c6563692e636f6d2f67682f68616c6c696e64617669642f6d616e6e792e7376673f7374796c653d737667)

Manny (Short for Manipulators)
==============================

[](#manny-short-for-manipulators)

a light-weight PHP package of useful common manipulators/formatters.

Installation with Composer
--------------------------

[](#installation-with-composer)

```
composer require hallindavid/manny
```

if using Laravel, the Manny alias should be autodiscovered and usable easily like this.

```
use Manny;

Manny::phone("8008008000"); // Returns: 800-800-8000
```

for other frameworks, you will likely need to do

```
require_once "vendor/autoload.php"
use Manny;
Manny::phone("8008008000"); // Returns: 800-800-8000
```

### Manny::phone

[](#mannyphone)

Manny::phone - a Canada/US phone formatter - rebuilt better than before from [hallindavid/phonehelper](https://github.com/hallindavid/phonehelper)

**Definition**

```
/**
* @param string $number
* @param array $options
*
*
* Default Options
*
*    $default_options = [
*        'showCountryCode'         => false,
*        'showAreaCode'            => true,
*        'showExchange'            => true,
*        'showLine'                => true,
*        'showExtension'           => false,
*        'prefix'                  => false,
*        'country_area_delimiter'  => false,
*        'area_exchange_delimiter' => '-',
*        'exchange_line_delimiter' => '-',
*        'line_extension_delimiter'=> ' ext. ',
*    ];
* @return string
*/
function phone($number, $options)
```

**Example**

```
Manny::phone("8008008000");
//outputs 800-800-8000
```

**Extending Manny::phone**

It's pretty easy to extend the phone class - here is an example

```
class Brack10 extends Manny\Phone
{
    public function __construct($text)
    {
        parent::__construct($text);
        $this->showCountryCode = false;
        $this->showAreaCode = true;
        $this->showExchange = true;
        $this->showLine = true;
        $this->showExtension = false;
        $this->prefix = false;
        $this->country_area_delimiter = '(';
        $this->area_exchange_delimiter = ') ';
        $this->exchange_line_delimiter = '-';
        $this->line_extension_delimiter = ' ext. ';
    }
}

$phone = new Brack10("123456789123456");
$phone->format();
//Returns: (234) 567-8912
```

### Manny::mask

[](#mannymask)

A mask function for formatting fixed-length data. (great for real-time-masking with [livewire/livewire](https://github.com/livewire/livewire))

**Definition**

```
/**
 * @param string $target
 * @param string $pattern
 * @return string
 */
function mask($target, $pattern)
```

**Pattern creation**

`A` should be a placeholder for an alphabetical character
`1` should be a placeholder for a numeric character
all other characters are treated as formatting characters

**Example**

```
//US Social Security Number
Manny::mask("987654321", "111-11-1111"); //returns "987-65-4321"

//US Zip-code
Manny::mask("The whitehouse zip code is: 20500", "11111"); //returns "20500"

//Canada Postal Code
Manny::mask("K1M1M4", "A1A 1A1"); //

//outputs 987-65-4321
```

### Manny::yoink

[](#mannyyoink)

use yoink to pull specific key-values from an associative array, and (optionally) pass in defaults.

**Definition**

```
/**
 * @param array $target - should be key-val associative array
 * @param array $elements - should be flat array with desired key names from target array
 * @param array $defaults (optional) - key-val associative array which will be appended to extracted key-value pairs before returning
 * @return array
 */
function yoink($target, $elements, $defaults = null)
```

**Example**

```
$array = ['id'  => '17', 'name'=> 'John Doe'];
$elements = ['name', 'role'];
$default_values = ['role'=> 'member'];
Manny::yoink($array, $elements, $default_values);  //Returns: ['name'=>'John Doe','role'=>'member'] ;
```

### Manny::stripper

[](#mannystripper)

a preg\_replace abstraction easy-to-remember parameters to reduce frequent googling

**Definition**

```
/**
 * @param string     $text    - the subject of our stripping
 * @param array|null $options - an array with the return types you'd like
 *
 *  keys can include the following types:
 *  alpha - keep the alphabetical characters (case-insensitive)
 * 	num - keep the digits (0-9)
 *  comma - keep commas
 *  colon - keep the : character
 *  dot - keep periods
 *  dash - keep dashes/hyphens
 *  space - keep spaces
 *  underscore - keep underscores
 *  pipe - keep pipe characters
 *  bracket - keep square brackets []
 *  parenthesis - keep parenthesis ()
 *  curly - keep curley braces (useful for handlebar syntax ex. {{ thing }}
 *
 * @return string
 */
function stripper($text, $options = null)
```

**Example**

```
$string = 'With only 5-10 hours of development, Dave built Manny, saving him atleast 10 seconds per day!';
$config = ['num', 'alpha', 'space'];
Manny::stripper($string,$config);
//Returns: 'With only 510 hours of development Dave built Manny saving him atleast 10 seconds per day';

$alt_config = ['num'];
Manny::stripper($string,$alt_config);
//Returns: '51010';
```

### Manny::keep

[](#mannykeep)

an alias for the `Manny::stripper` with the same functionality (since you are really "keeping" all the characters you define in the options, it makes for better code readability)

**Example**

```
$string = 'I only want to "keep" the alpha, num, and spaces for this string!';
$options = ['alpha', 'num', 'space']
Manny::keep()
//Returns: 'I only want to keep the alpha num and spaces for this string'
```

### Manny::crumble

[](#mannycrumble)

a preg\_replace abstraction easy-to-remember parameters to reduce frequent googling

**Definition**

```
    /**
     * @param string $text - the subject of our crumbling
     * @param array $crumbs - an array of positive integers
     * @param bool $appendExtra - keys can include the following types
     *
     * @return array
     */
    function crumble($string, $crumbs, $appendExtra = false)

```

**Example**

```
Manny::crumble("18008008000888", [1,3,3,4])
//Output: ["1","800","800","8000"];

//with append extra
Manny::crumble("18008008000888", [1,3,3,4],true)
//Output: ["1","800","800","8000", "888"];
```

### Manny::percent

[](#mannypercent)

This is a quick-use tool for generating percents. It cleans up bad data before processing, and has an opinionated workflow (eg. 0/0 = 100%)

**Definition**

```
    /**
     * @param int|float|string $num - the numerator
     * @param int|float|string $denom - the denominator
     * @param int $precision - keys can include the following types
     *
     * @return float
     */
    function percent($num, $denom, $precision = 0)

```

**Example**

```
Manny::percent(1,8);
//Output: 12.5;
```

Testing
-------

[](#testing)

There are a tonne of tests for the packaged formats - to run them, pull the package then

```
composer install
composer test

```

Support
-------

[](#support)

To say thanks, you can share the project on social media or

[![Buy Me A Coffee](https://camo.githubusercontent.com/9f44ce2dc3b3eecdd02598900866ffc518801df1932849703dae1e5ce5031070/68747470733a2f2f7777772e6275796d6561636f666665652e636f6d2f6173736574732f696d672f637573746f6d5f696d616765732f6f72616e67655f696d672e706e67)](https://www.buymeacoffee.com/tDbQ4kg)

Issues
------

[](#issues)

Please report all issues in the GitHub Issue tracker

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

[](#contributing)

Shoot me an email, or DM me on twitter and I am happy to allow other contributors.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance54

Moderate activity, may be stable

Popularity43

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.2% 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 ~408 days

Total

3

Last Release

1248d ago

PHP version history (3 changes)v1.0PHP ^7.2

v1.01PHP ^7.2|^8.0

v1.02PHP ^7.2|^8

### Community

Maintainers

![](https://www.gravatar.com/avatar/94662fba8d9e407e1edae89161dd8894bb389fa5d74403688023bdc3866d37fd?d=identicon)[hallindavid](/maintainers/hallindavid)

---

Top Contributors

[![hallindavid](https://avatars.githubusercontent.com/u/53200282?v=4)](https://github.com/hallindavid "hallindavid (30 commits)")[![pjkellar](https://avatars.githubusercontent.com/u/14946432?v=4)](https://github.com/pjkellar "pjkellar (4 commits)")

---

Tags

formatterlaravelstringmanipulationformatregexnumbertrim

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hallindavid-manny/health.svg)

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

###  Alternatives

[kwn/number-to-words

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

4235.0M21](/packages/kwn-number-to-words)[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)
