PHPackages                             gears/string - 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. gears/string

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

gears/string
============

A collection of basic string manipulation functions.

v1.1.1(9y ago)4229.8k↓32.5%119MITPHPPHP ^5.4 || ^7.0

Since Jul 19Pushed 7y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (9)Versions (15)Used By (9)

> 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 Gears\String\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ÀŘ'
```

`Gears\String\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)

`Gears\String\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 `Gears\String\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

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~94 days

Recently: every ~57 days

Total

14

Last Release

3456d ago

Major Versions

v0.6.0 → v1.0.0-RC12016-04-13

PHP version history (2 changes)v0.1PHP &gt;=5.3

v1.0.0-RC1PHP ^5.4 || ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2b476564958ffc91db5580080738e529644f820bdfec6a6c4d397f9c5da45065?d=identicon)[brad-jones](/maintainers/brad-jones)

---

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)")

---

Tags

stringmanipulation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gears-string/health.svg)

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

###  Alternatives

[doctrine/inflector

PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.

11.4k855.8M711](/packages/doctrine-inflector)[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.0M191](/packages/danielstjules-stringy)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[voku/stringy

A string manipulation library with multibyte support

1783.8M19](/packages/voku-stringy)[statamic/stringy

A string manipulation library with multibyte support, forked from @statamic

234.5M14](/packages/statamic-stringy)[opis/string

Multibyte strings as objects

7420.9M7](/packages/opis-string)

PHPackages © 2026

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