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

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

leobenoist/string-helper
========================

PHP StringHelper is a small library that can perform string manipulation.

v1.0.3(5y ago)05.5kMITPHPPHP &gt;=7.1CI failing

Since Apr 8Pushed 4y ago2 watchersCompare

[ Source](https://github.com/LeoBenoist/StringHelper)[ Packagist](https://packagist.org/packages/leobenoist/string-helper)[ RSS](/packages/leobenoist-string-helper/feed)WikiDiscussions master Synced 3w ago

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

StringHelper
============

[](#stringhelper)

Usage:
------

[](#usage)

### StringHelper::toUpperCamelCase($string)

[](#stringhelpertouppercamelcasestring)

```
    use LeoBenoist\StringHelper\StringHelper;

    StringHelper::toUpperCamelCase('CamelCase');
    StringHelper::toUpperCamelCase('camelCase');
    StringHelper::toUpperCamelCase('camel_case');
    StringHelper::toUpperCamelCase('camel case');
```

Result: `CamelCase`

### StringHelper::toLowerCamelCase($string)

[](#stringhelpertolowercamelcasestring)

```
    use LeoBenoist\StringHelper\StringHelper;

    StringHelper::toLowerCamelCase('CamelCase');
    StringHelper::toLowerCamelCase('camelCase');
    StringHelper::toLowerCamelCase('camel_case');
    StringHelper::toLowerCamelCase('camel case');
    StringHelper::toLowerCamelCase('camel Case');
```

Result: `camelCase`

### StringHelper::toSnakeCase($string)

[](#stringhelpertosnakecasestring)

```
    use LeoBenoist\StringHelper\StringHelper;

    StringHelper::toSnakeCase('SnakeCase');
    StringHelper::toSnakeCase('snakeCase');
    StringHelper::toSnakeCase('snake_case');
    StringHelper::toSnakeCase('snake case');
    StringHelper::toSnakeCase('snake Case');
```

Result: `snake_case`

### StringHelper::toLowerCase($string)

[](#stringhelpertolowercasestring)

```
    use LeoBenoist\StringHelper\StringHelper;

    StringHelper::toLowerCase('LowerCase');
    StringHelper::toLowerCase('lowerCase');
    StringHelper::toLowerCase('lower_case');
    StringHelper::toLowerCase('lower case');
    StringHelper::toLowerCase('lower Case');
```

Result: `lower case`

### StringHelper::toHumanCase($string)

[](#stringhelpertohumancasestring)

```
    use LeoBenoist\StringHelper\StringHelper;

    StringHelper::toHumanCase('HumanCase');
    StringHelper::toHumanCase('humanCase');
    StringHelper::toHumanCase('human_case');
    StringHelper::toHumanCase('human case');
    StringHelper::toHumanCase('human Case');
```

Result: `Human case`

### StringHelper::endWith(string $haystack, string $needle)

[](#stringhelperendwithstring-haystack-string-needle)

```
    use LeoBenoist\StringHelper\StringHelper;

    StringHelper::endsWith('WillItEndWithTheWordEnd', 'End');
```

Result: `true`

### StringHelper::startsWith(string $haystack, string $needle)

[](#stringhelperstartswithstring-haystack-string-needle)

```
    use LeoBenoist\StringHelper\StringHelper;

    StringHelper::startsWith('WillItStartsWithTheWordWill', 'Will');
```

Result: `true`

### StringHelper::extractPrefix(string $haystack, string $separator = '-')

[](#stringhelperextractprefixstring-haystack-string-separator---)

```
    use LeoBenoist\StringHelper\StringHelper;

    StringHelper::extractPrefix('pre-fix');
    StringHelper::extractPrefix('pre-bla-fix');
```

Result: `pre`

### StringHelper::extractSuffix(string $haystack, string $separator = '-')

[](#stringhelperextractsuffixstring-haystack-string-separator---)

```
    use LeoBenoist\StringHelper\StringHelper;

    StringHelper::extractSuffix('suf-fix');
    StringHelper::extractSuffix('suf-bla-fix');
    StringHelper::extractSuffix('suf#fix', '#');
```

Result: `fix`

### StringHelper::removePrefix(string $haystack, string $separator = '-')

[](#stringhelperremoveprefixstring-haystack-string-separator---)

```
    use LeoBenoist\StringHelper\StringHelper;

    StringHelper::removePrefix('pre-fix');
    StringHelper::removePrefix('pre#fix', '#');
```

Result: `fix`

### StringHelper::removeSuffix(string $haystack, string $separator = '-')

[](#stringhelperremovesuffixstring-haystack-string-separator---)

```
    use LeoBenoist\StringHelper\StringHelper;

    StringHelper::removeSuffix('pre-fix');
    StringHelper::removeSuffix('pre#fix', '#');
```

Result: `pre`

### StringHelper::stringContains(string $haystack, string $needle)

[](#stringhelperstringcontainsstring-haystack-string-needle)

```
    use LeoBenoist\StringHelper\StringHelper;

    $this->assertTrue(StringHelper::contains('It is better to offer no excuse than a bad one.', 'better');
```

Result: `true`

Run tests
---------

[](#run-tests)

` ./vendor/phpunit/phpunit/phpunit`

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

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

Total

4

Last Release

2002d ago

PHP version history (2 changes)v1.0.0PHP ^7.1

v1.0.3PHP &gt;=7.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2912614?v=4)[Léo Benoist](/maintainers/LeoBenoist)[@LeoBenoist](https://github.com/LeoBenoist)

---

Top Contributors

[![LeoBenoist](https://avatars.githubusercontent.com/u/2912614?v=4)](https://github.com/LeoBenoist "LeoBenoist (3 commits)")

---

Tags

phpmanipulationstringslowercasewordsuppercaseprefixcamelcasesnakecasesuffixstartwithendwith

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  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.3k885.0M822](/packages/doctrine-inflector)[mattketmo/camel

Tiny library to handle words case transformation

29373.8k17](/packages/mattketmo-camel)[glowy/strings

Strings Component provide a fluent, object-oriented interface for working with multibyte string, allowing you to chain multiple string operations together using a more readable syntax compared to traditional PHP strings functions.

183.4k2](/packages/glowy-strings)

PHPackages © 2026

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