PHPackages                             thestringler/manipulator - 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. thestringler/manipulator

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

thestringler/manipulator
========================

An OOP approach to string manipulation.

v2.2.1(6y ago)345.5k4[1 issues](https://github.com/mattsparks/the-stringler/issues)2MITPHPPHP &gt;=7.0

Since Jun 30Pushed 6y ago4 watchersCompare

[ Source](https://github.com/mattsparks/the-stringler)[ Packagist](https://packagist.org/packages/thestringler/manipulator)[ RSS](/packages/thestringler-manipulator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (22)Used By (2)

The Stringler
=============

[](#the-stringler)

A simple class to manipulate strings in an OO way. Inspired by [Spatie's String](https://github.com/spatie/string). Just built this for fun. Hope you like it.

Install
-------

[](#install)

Via composer:

```
composer require thestringler/manipulator
```

Using Laravel? Checkout [The Stringler Laravel Package](https://github.com/mattsparks/the-stringler-laravel).

Methods
-------

[](#methods)

### append($string)

[](#appendstring)

```
Manipulator::make('Freak')->append(' Out!');
// Freak Out!
```

### camelToSnake

[](#cameltosnake)

```
Manipulator::make('camelCase')->camelToSnake();
// camel_case
```

### camelToClass

[](#cameltoclass)

```
Manipulator::make('className')->camelToClass();
// ClassName
```

### capitalize

[](#capitalize)

```
Manipulator::make('hello')->capitalize();
// Hello
```

### capitalizeEach

[](#capitalizeeach)

```
Manipulator::make('i like toast!')->capitalizeEach();
// I Like Toast!
```

### custom

[](#custom)

```
Manipulator::make('Some String')->custom(function ($string) {
    // This is just a sample, this can be achieved with existing methods,
    // But you can do whatever string manipulation you want here.
    return ucfirst(strtolower($string));
});
// Some string
```

### eachCharacter($closure)

[](#eachcharacterclosure)

```
Manipulator::make('hello')->eachCharacter(function($char) {
    return strtoupper($char);
});
// HELLO
```

### eachWord($closure, $preserveSpaces = false)

[](#eachwordclosure-preservespaces--false)

```
Manipulator::make('hello moto')->eachWord(function($word) {
    return strrev($word);
});
// ollehotom

Manipulator::make('hello moto')->eachWord(function($word) {
    return strrev($word);
}, true);
// olleh otom
```

### getPossessive

[](#getpossessive)

```
Manipulator::make('Bob')->getPossessive();
// Bob's
Manipulator::make('Silas')->getPossessive();
// Silas'
```

### htmlEntities($flags = ENT\_HTML5, $encoding = 'UTF-8', $doubleEncode = true)

[](#htmlentitiesflags--ent_html5-encoding--utf-8-doubleencode--true)

```
Manipulator::make('&')->htmlEntities();
// &amp;
```

### htmlEntitiesDecode($flags = ENT\_HTML5, $encoding = 'UTF-8')

[](#htmlentitiesdecodeflags--ent_html5-encoding--utf-8)

```
Manipulator::make('&amp;')->htmlEntitiesDecode();
// &
```

### htmlSpecialCharacters($flags = ENT\_HTML5, $encoding = 'UTF-8', $doubleEncode = true)

[](#htmlspecialcharactersflags--ent_html5-encoding--utf-8-doubleencode--true)

```
Manipulator::make('&')->htmlSpecialCharacters();
// &amp;&lt;&gt;
```

### lowercaseFirst

[](#lowercasefirst)

```
Manipulator::make('HELLO')->lowercaseFirst();
// hELLO
```

### make($string)

[](#makestring)

```
// Named constructor
Manipulator::make('string');
```

### pad($length, $string, $type = null)

[](#padlength-string-type--null)

```
Manipulator::make('Hello')->pad(2, '!!', STR_PAD_RIGHT);
// Hello!!
```

### prepend($string)

[](#prependstring)

```
Manipulator::make('is the one.')->prepend('Neo ');
// Neo is the one.
```

### pluralize($items = null)

[](#pluralizeitems--null)

```
Manipulator::make('Potato')->pluralize();
// Potatoes
```

You can optionally pass an array or numeric value to `pluaralize` to determine if the given string should be pluaralized.

```
$dogs = ['Zoe', 'Spot', 'Pickles'];
Manipulator::make('Dog')->pluralize($dogs);
// Dogs

$cats = ['Whiskers'];
Manipulator::make('Cat')->pluralize($cats);
// Cat
```

### nthCharacter($nth, $closure)

[](#nthcharacternth-closure)

```
Manipulator::make('Wordpress')->nthCharacter(5, function($character) {
    return mb_strtoupper($character);
});
// WordPress
```

### nthWord($nth, $closure, $preserveSpaces = true)

[](#nthwordnth-closure-preservespaces--true)

```
Manipulator::make('Oh hello there!')->nthWord(2, function($word) {
    return mb_strtoupper($word);
});
// Oh HELLO there!
```

### remove($string, $caseSensitive = true)

[](#removestring-casesensitive--true)

```
Manipulator::make('Dog Gone')->remove('Gone');
// Dog
```

### removeSpecialCharacters($exceptions = \[\])

[](#removespecialcharactersexceptions--)

```
Manipulator::make('Hello!!')->removeSpecialCharacters();
// Hello
Manipulator::make('Hello!!')->removeSpecialCharacters(['!']);
// Hello!!
```

### repeat($multiplier = 1)

[](#repeatmultiplier--1)

```
Manipulator::make('la')->repeat(3);
// lalala
```

### replace($find, $replace = '', $caseSensitive = true)

[](#replacefind-replace---casesensitive--true)

```
Manipulator::make('Pickles are good.')->replace('good', 'terrible');
// Pickles are terrible.
```

### reverse

[](#reverse)

```
Manipulator::make('Whoa!')->reverse();
// !aohW
```

### snakeToCamel

[](#snaketocamel)

```
Manipulator::make('snake_case')->snakeToCamel();
// snakeCase
```

### snakeToClass

[](#snaketoclass)

```
Manipulator::make('class_name')->snakeToClass();
// ClassName
```

### stripTags($allowed = '')

[](#striptagsallowed--)

```
Manipulator::make('Hello')->stripTags();
// Hello
```

### toCamelCase

[](#tocamelcase)

```
Manipulator::make('camel case')->toCamelCase();
// camelCase
```

### toL33t

[](#tol33t)

```
Manipulator::make('Hack The Planet!')->toL33t();
// (-)@{|< +/-/€ |O7@|\|€][!
```

### toLower

[](#tolower)

```
Manipulator::make('LOWER')->toLower();
// lower
```

### toSlug

[](#toslug)

```
Manipulator::make('This is a slug!')->toSlug();
// this-is-a-slug
```

### toSnakeCase

[](#tosnakecase)

```
Manipulator::make('snake case')->toSnakeCase();
// snake_case
```

### toString

[](#tostring)

This method just returns the string.

### toUpper

[](#toupper)

```
Manipulator::make('upper')->toUpper();
// UPPER
```

### trim

[](#trim)

```
Manipulator::make('  trimmed  ')->trim();
// trimmed
```

### trimBeginning

[](#trimbeginning)

```
Manipulator::make('  trimmed')->trimBeginning();
// trimmed
```

### trimEnd

[](#trimend)

```
Manipulator::make('trimmed  ')->trimEnd();
// trimmed
```

### truncate($length = 100, $append = '...')

[](#truncatelength--100-append--)

```
Manipulator::make('This is a sentence and will be truncated.')->truncate(10, '...');
// This is a ...
```

### urlDecode

[](#urldecode)

```
Manipulator::make('hello%21')->urlDecode();
// hello!
```

### urlEncode

[](#urlencode)

```
Manipulator::make('hello!')->urlEncode();
// hello%21
```

Chainable
---------

[](#chainable)

All of these methods (minus `toString`) can be chained.

```
Manipulator::make('hello')->toUpper()->reverse();
// OLLEH
```

Contribute
----------

[](#contribute)

Contributions are very welcome!

1. Follow the [PSR-2 Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
2. Send a pull request.

That's pretty much it!

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~64 days

Recently: every ~239 days

Total

19

Last Release

2456d ago

Major Versions

v0.8.0 → v1.0.02016-08-06

v1.3.0 → v2.0.02017-01-30

### Community

Maintainers

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

---

Top Contributors

[![mattsparks](https://avatars.githubusercontent.com/u/1678388?v=4)](https://github.com/mattsparks "mattsparks (36 commits)")[![ahuggins](https://avatars.githubusercontent.com/u/1791228?v=4)](https://github.com/ahuggins "ahuggins (3 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (3 commits)")[![NorcalAussie](https://avatars.githubusercontent.com/u/1586324?v=4)](https://github.com/NorcalAussie "NorcalAussie (2 commits)")[![kherrick](https://avatars.githubusercontent.com/u/3065761?v=4)](https://github.com/kherrick "kherrick (1 commits)")

---

Tags

laravelmanipulating-stringsoopphpstring-manipulationstrings

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/thestringler-manipulator/health.svg)

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

###  Alternatives

[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k111.1M568](/packages/symfony-maker-bundle)[illuminate/support

The Illuminate Support package.

582107.1M34.5k](/packages/illuminate-support)[stoutlogic/acf-builder

An Advanced Custom Field Configuration Builder

8311.8M60](/packages/stoutlogic-acf-builder)[sculpin/sculpin

Static Site Generator

1.5k102.8k12](/packages/sculpin-sculpin)[kms/froala-editor-bundle

Provides a Froala editor integration for Symfony 4 &amp; 5.

110272.8k](/packages/kms-froala-editor-bundle)[wyrihaximus/react-child-process-messenger

Messenger decorator for react/child-process

32279.4k4](/packages/wyrihaximus-react-child-process-messenger)

PHPackages © 2026

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