PHPackages                             tualo/stringgear - 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. tualo/stringgear

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

tualo/stringgear
================

A collection of basic string manipulation functions.

00PHP

Since Aug 6Pushed 9mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

> Looking for maintainers, I no longer do much if any PHP dev, I have moved on, mostly work in dotnet core, node.js &amp; golang these days. If anyone is keen to take over these projects, get in touch -

The String Gear
===============

[](#the-string-gear)

[![Build Status](https://camo.githubusercontent.com/a190cc203039b64c10bd6ea8cc187b759d720e3b4855b0546dfb23a620ba627e/68747470733a2f2f7472617669732d63692e6f72672f70687067656172626f782f737472696e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/phpgearbox/string)[![Windows Build Status](https://camo.githubusercontent.com/b28ae7d981d2974f6ca201d71656ea33ef13800dd1190bbc2e8c78233f69ca51/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f386a6a3977787579666b61726f7331773f7376673d74727565)](https://ci.appveyor.com/project/brad-jones/string)[![Latest Stable Version](https://camo.githubusercontent.com/d2800822527a6decf0a8ab4506574de0a4a73cb24eac2d6df5e90686f26fd43b/68747470733a2f2f706f7365722e707567782e6f72672f67656172732f737472696e672f762f737461626c652e737667)](https://packagist.org/packages/gears/string)[![Total Downloads](https://camo.githubusercontent.com/4337a01661dd96e5580b2431bde50b7e08ae422e6e89a9acab29642bc5fc8b63/68747470733a2f2f706f7365722e707567782e6f72672f67656172732f737472696e672f646f776e6c6f6164732e737667)](https://packagist.org/packages/gears/string)[![License](https://camo.githubusercontent.com/b72a3b19e6ed88dd727b61722375219d8d04e4c653fcf3e46d241e6ea184f710/68747470733a2f2f706f7365722e707567782e6f72672f67656172732f737472696e672f6c6963656e73652e737667)](https://packagist.org/packages/gears/string)[![HHVM Tested](https://camo.githubusercontent.com/f8d674aad2bee3f9c75f53cc2140140aadacc7f3b815e8c10923c1e26c243ee4/687474703a2f2f6868766d2e683463632e64652f62616467652f67656172732f737472696e672e7376673f7374796c653d666c6174)](http://hhvm.h4cc.de/package/gears/string)[![Coverage Status](https://camo.githubusercontent.com/27510de85c62cf83763d8ffb527c94e93c105c035ae550e3c68db52f35f166ea/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f70687067656172626f782f737472696e672f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/phpgearbox/string?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e97688a2acbcfa1a4a7616b1a2c4b5588727a454578834b3d5f16180af8cd06d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70687067656172626f782f737472696e672f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/phpgearbox/string/?branch=master)

An object oriented way to work with strings in PHP, with multibyte support baked in.

Credit &amp; Inspiration
------------------------

[](#credit--inspiration)

The original library The voku fork

This version builds on voku's work. The main aim was to make the management of the code base easier by splitting the mountain of methods that make up the Stringy class into traits.

This does mean we have bumped the minimum PHP version to 5.4+

> NOTE: There are also a few other changes, this is not an API compatible fork.

How to Install
--------------

[](#how-to-install)

Installation via composer is easy:

```
composer require gears/string

```

Then import the `Str` class into your script:

```
use Tualo\StringGear\Str;
```

OO and Chaining
---------------

[](#oo-and-chaining)

The library offers OO method chaining, as seen below:

```
echo Str::s('fòô     bàř')->removeWhitespace()->swapCase(); // 'FÒÔ BÀŘ'
```

`Tualo\StringGear\Str` has a `__toString()` method, which returns the current string when the object is used in a string context, ie: `(string) Str::s('foo')`

Implemented Interfaces
----------------------

[](#implemented-interfaces)

`Tualo\StringGear\Str` implements the `IteratorAggregate` interface, meaning that `foreach` can be used with an instance of the class:

```
$str = Str::s('fòôbàř');
foreach ($str as $char) {
    echo $char;
}
// 'fòôbàř'
```

It implements the `Countable` interface, enabling the use of `count()` to retrieve the number of characters in the string:

```
$str = Str::s('fòô');
count($str);  // 3
```

Furthermore, the `ArrayAccess` interface has been implemented. As a result, `isset()` can be used to check if a character at a specific index exists. And since `Tualo\StringGear\Str` is immutable, any call to `offsetSet` or `offsetUnset`will throw an exception. `offsetGet` has been implemented, however, and accepts both positive and negative indexes. Invalid indexes result in an `OutOfBoundsException`.

```
$str = Str::s('bàř');
echo $str[2];     // 'ř'
echo $str[-2];    // 'à'
isset($str[-4]);  // false

$str[3];          // OutOfBoundsException
$str[2] = 'a';    // Exception
```

The Methods
-----------

[](#the-methods)

All methods are documented with PSR-5 docblocks that provide autocomplete hints to any decent IDE such as [PHP Storm](https://www.jetbrains.com/phpstorm/) or Atom with [atom-autocomplete-php](https://atom.io/packages/atom-autocomplete-php).

---

Developed by Brad Jones -

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance41

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/329ac1f2a4f83be89056acc761999cdc6baaf24b63318c371d3e1a950ad45d9f?d=identicon)[tualo](/maintainers/tualo)

---

Top Contributors

[![brad-jones](https://avatars.githubusercontent.com/u/2754772?v=4)](https://github.com/brad-jones "brad-jones (36 commits)")[![voku](https://avatars.githubusercontent.com/u/264695?v=4)](https://github.com/voku "voku (1 commits)")

### Embed Badge

![Health badge](/badges/tualo-stringgear/health.svg)

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

###  Alternatives

[dazet/data-map

Library for mapping data structures.

2123.7k](/packages/dazet-data-map)

PHPackages © 2026

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