PHPackages                             pataar/smartstring - 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. pataar/smartstring

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

pataar/smartstring
==================

A class to manipulate a string with a better syntax.

1.0.1(10y ago)417MITPHP

Since Jun 18Pushed 8y ago1 watchersCompare

[ Source](https://github.com/pataar/smartstring)[ Packagist](https://packagist.org/packages/pataar/smartstring)[ RSS](/packages/pataar-smartstring/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (3)Used By (0)

SmartString
===========

[](#smartstring)

### Installation

[](#installation)

Using Composer:

```
composer require pataar/smartstring
```

### Usage

[](#usage)

##### Creating a SmartString object

[](#creating-a-smartstring-object)

Either do

```
\Pataar\SmartString::create("Sample String");
```

Or

```
new \Pataar\SmartString("Sample String");
```

##### Using a SmartString object

[](#using-a-smartstring-object)

After creating your SmartString, you can use several chainable methods to manipulate the string.

Some examples:

```
$sampletext = "Sample String";

echo \Pataar\SmartString::create($sampletext)->remove("String")->trim();
//which would echo "Sample"

echo \Pataar\SmartString::create($sampletext)->prefix("A new ")->normalize();
//which would echo "a-new-sample-string"

echo \Pataar\SmartString::create($sampletext)->toMd5WithSalt("Salting is good");
//which would echo "560fbd0056c4354c5dd0de0580c8c523"

echo \Pataar\SmartString::create($sampletext)->remove("String")->trim()->toLower()->prefix("String ");
//which would echo "String sample"
```

### Functions

[](#functions)

#### toUpper()

[](#toupper)

Creates an uppercase version of the string.

```
$smartString->toUpper();
```

#### toLower()

[](#tolower)

Creates an lowercase version of the string.

```
$smartString->toLower();
```

#### Trim()

[](#trim)

Trims the string. So removes any trailing whitespaces and spaces.

```
$smartString->trim();
```

#### printme()

[](#printme)

Prints the string.

```
$smartString->printme();
```

#### indexOf($input)

[](#indexofinput)

Returns the index of a certain $input string.

```
$smartString->indexOf($input);
```

#### substring($start, $length)

[](#substringstart-length)

Creates a substring of an existing string.

```
$smartString->substring($start, $length);
```

#### toMd5()

[](#tomd5)

Creates an MD5 hash of the string.

```
$smartString->toMd5();
```

#### toMd5WithSalt($salt)

[](#tomd5withsaltsalt)

Creates an salted MD5 hash of the string. Using both a prefix and suffix containing the given `$salt`.

```
$smartString->toMd5WithSalt($salt);
```

#### encodeB64() || decodeB64()

[](#encodeb64--decodeb64)

Encodes or decodes a B64 string.

```
$smartString->encodeB64();
$smartString->decodeB64();
```

#### charAt($index)

[](#charatindex)

Tells you on which index a certain character is placed.

```
$smartString->charAt($index);
```

#### equals($string)

[](#equalsstring)

Returns when the $string matches the $smartString.

```
$smartString->equals($string);
```

#### prefix($prefix)

[](#prefixprefix)

Adds a $prefix to the string.

```
$smartString->prefix($prefix);
```

#### suffix($suffix)

[](#suffixsuffix)

Adds a $suffix to the string.

```
$smartString->suffix($suffix);
```

#### concat($string)

[](#concatstring)

Concats a string.

```
$smartString->concat($string);
```

#### replace($search, $replacement)

[](#replacesearch-replacement)

Replace a string with an other string.

```
$smartString->replace($search, $replacement);
```

#### replacePattern($pattern, $replacement)

[](#replacepatternpattern-replacement)

Replaces a pattern.

```
$smartString->replacePattern($pattern, $replacement);
```

#### remove($string)

[](#removestring)

Remove a string

```
$smartString->remove($string);
```

#### length()

[](#length)

Returns the length of the string.

```
$smartString->length();
```

#### normalize()

[](#normalize)

Normalizes the string. Making it URL/slug compatible.

```
$smartString->normalize();
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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

3656d ago

### Community

Maintainers

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

---

Top Contributors

[![pataar](https://avatars.githubusercontent.com/u/3403851?v=4)](https://github.com/pataar "pataar (17 commits)")

### Embed Badge

![Health badge](/badges/pataar-smartstring/health.svg)

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

PHPackages © 2026

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