PHPackages                             konexia/super-str - 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. konexia/super-str

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

konexia/super-str
=================

A helper library for string manipulation with chaining capabilities.

v1.1.0(1y ago)15MITPHP

Since Nov 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/CarlosMtnez/super-str)[ Packagist](https://packagist.org/packages/konexia/super-str)[ RSS](/packages/konexia-super-str/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

SuperStr Documentation
======================

[](#superstr-documentation)

🚀 SuperStr: Simple, Flexible String Manipulation for PHP 💥
----------------------------------------------------------

[](#-superstr-simple-flexible-string-manipulation-for-php-)

SuperStr is a simple yet powerful PHP library designed to make string manipulation easy and fun. 😎 It provides a set of simple methods that can be chained together to keep your code clean, with a short syntax. 🌟

Some key features include:

- **Chaining Methods**: Combine methods POO, short and clean syntax.
- **Helper Functions and Static Methods**: Use it the way you prefer, whether through a helper function, static class, or as an instance.
- **Multilingual Support**: Multibyte UTF-8 support, handles special characters and accents. 🌍

Start using SuperStr very easy with composer. 🌬️

Installation
------------

[](#installation)

To install the SuperStr library using Composer, run the following command:

```
composer require konexia/super-str
```

Usage
-----

[](#usage)

SuperStr can be used in three different ways:

1. **Using the Helper Function**: `super_str(string $value)`
2. **Using the Static Class**: `Sstr::set(string $value)`
3. **Using an Instance of SuperStr**: `SuperStr->getInstance(?string $value)`

### Examples of Usages

[](#examples-of-usages)

```
//1.Function
echo super_str('hello')->toUpper()->append(' WORLD')->get();
// Outputs: HELLO WORLD

//2.Static Class
echo Sstr::set('hello')->toUpper()->append(' WORLD')->get();
// Outputs: HELLO WORLD

//3.Instance
$myStr = SuperStr->getInstance('hello');
echo $myStr->toUpper()->append(' WORLD')->get();
// Outputs: HELLO WORLD
```

Methods and Examples
--------------------

[](#methods-and-examples)

### `slugify(?int $length = null): self`

[](#slugifyint-length--null-self)

Converts the string into a URL-friendly slug. Optionally, you can limit the length of the slug.

**Example:**

```
echo super_str('Hello World!')->slugify()->get();
// Outputs: hello-world
```

**Example with length limit:**

```
echo super_str('Hello Beautiful World!')->slugify(10)->get();
// Outputs: hello-beau
```

### `prepend(string $prefix): self`

[](#prependstring-prefix-self)

Adds a prefix to the string.

**Example:**

```
echo super_str('world')->prepend('hello ')->get();
// Outputs: hello world
```

### `append(string $suffix): self`

[](#appendstring-suffix-self)

Adds a suffix to the string.

**Example:**

```
echo super_str('hello')->append(' world')->get();
// Outputs: hello world
```

### `toUpper(): self`

[](#toupper-self)

Converts the string to uppercase.

**Example:**

```
echo super_str('hello world')->toUpper()->get();
// Outputs: HELLO WORLD
```

### `toLower(): self`

[](#tolower-self)

Converts the string to lowercase.

**Example:**

```
echo super_str('HELLO WORLD')->toLower()->get();
// Outputs: hello world
```

### `capitalize(): self`

[](#capitalize-self)

Capitalizes the first character of the string.

**Example:**

```
echo super_str('hELLO wORLD')->capitalize()->get();
// Outputs: Hello world
```

### `extractBetween(?string $start, ?string $end): ?string`

[](#extractbetweenstring-start-string-end-string)

Extracts a substring between a start and an optional end string.

**Example:**

```
echo super_str('Hello [world]!')->extractBetween('[', ']');
// Outputs: world
```

### `do(callable $callback): self`

[](#docallable-callback-self)

Applies a custom function to the string value.

**Example:**

```
echo super_str('hello')->do( function($value) {
        return strtoupper($value);
    })->get();
// Outputs: HELLO
```

### `replace(string $search, string $replace, bool $caseSensitive = true): self`

[](#replacestring-search-string-replace-bool-casesensitive--true-self)

Replaces occurrences of a substring with another string. Supports case sensitivity.

**Example (Case Sensitive):**

```
echo super_str('Hello World')->replace('World', 'PHP')->get();
// Outputs: Hello PHP
```

**Example (Case Insensitive):**

```
echo super_str('Hello World')->replace('world', 'PHP', false)->get();
// Outputs: Hello PHP
```

### `contains(string $substring): self`

[](#containsstring-substring-self)

Checks if the string contains a given substring. If not found, skips further chaining.

**Example:**

```
echo super_str('Hello World')->contains('World')->toUpper()->get();
// Outputs: HELLO WORLD
```

### `notContains(string $substring): self`

[](#notcontainsstring-substring-self)

Checks if the string does not contain a given substring. If found, skips further chaining.

**Example:**

```
echo super_str('Hello World')->notContains('PHP')->toUpper()->get();
// Outputs: HELLO WORLD
```

### `if(callable $callback): self`

[](#ifcallable-callback-self)

Conditionally continues chaining if the given callback returns `true`.

**Example (Condition True):**

```
echo super_str('Hello')->if( function($value) {
    return $value === 'Hello';
})->append(' World')->get();
// Outputs: Hello World
```

**Example (Condition False):**

```
echo super_str('Hello')->if( function($value) {
    return $value === 'Goodbye';
})->append(' World')->get();
// Outputs: Hello
```

### `trim(): self`

[](#trim-self)

Trims whitespace from both ends of the string.

**Example:**

```
echo super_str('  Hello World  ')->trim()->get();
// Outputs: Hello World
```

### `ltrim(): self`

[](#ltrim-self)

Trims whitespace from the beginning of the string.

**Example:**

```
echo super_str('  Hello World')->ltrim()->get();
// Outputs: Hello World
```

### `rtrim(): self`

[](#rtrim-self)

Trims whitespace from the end of the string.

**Example:**

```
echo super_str('Hello World  ')->rtrim()->get();
// Outputs: Hello World
```

### `length(): int`

[](#length-int)

Gets the length of the current string.

**Example:**

```
echo super_str('Hello World')->length();
// Outputs: 11
```

Running Tests
-------------

[](#running-tests)

To run the tests for this library, use the following command:

```
vendor/bin/phpunit tests
```

Credits
-------

[](#credits)

- **Author**: Carlos Martínez
- **Konexia**

License
-------

[](#license)

This project is licensed under the MIT License.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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

Total

2

Last Release

559d ago

### Community

Maintainers

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

---

Top Contributors

[![CarlosMtnez](https://avatars.githubusercontent.com/u/30314879?v=4)](https://github.com/CarlosMtnez "CarlosMtnez (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/konexia-super-str/health.svg)

```
[![Health](https://phpackages.com/badges/konexia-super-str/health.svg)](https://phpackages.com/packages/konexia-super-str)
```

###  Alternatives

[adigital/gdprdatachecker

Run through the database and pull out any information associated with a specified email address

151.0k](/packages/adigital-gdprdatachecker)

PHPackages © 2026

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