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

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

napse/string-utils
==================

Lightweight string casing conversions and semantic versioning for PHP

v2.0.0(4mo ago)111MITPHPPHP &gt;=8.2

Since Feb 13Pushed 4mo agoCompare

[ Source](https://github.com/TheNapse/packagist-napse-string-utils)[ Packagist](https://packagist.org/packages/napse/string-utils)[ RSS](/packages/napse-string-utils/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (2)Versions (8)Used By (0)

napse/string-utils
==================

[](#napsestring-utils)

[![Packagist Version](https://camo.githubusercontent.com/c5141225504d9405f88024b3c9150b12fb7e940140ad51e70b9ce47d788ddc26/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e617073652f737472696e672d7574696c73)](https://packagist.org/packages/napse/string-utils)[![License](https://camo.githubusercontent.com/b687225836e17d6135cc1f1a341914f066fd889bfe5d9863efda75e2547eed60/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e617073652f737472696e672d7574696c73)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/6a13b62ce9ccbe599bc4730aa41afc9a7fd66af7ae19944edbf221e8fdd92c65/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6e617073652f737472696e672d7574696c732f706870)](composer.json)

Lightweight string casing conversions and semantic versioning for PHP.

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

[](#installation)

```
composer require napse/string-utils
```

Requires **PHP 8.2** or higher.

StringUtils
-----------

[](#stringutils)

Converts strings between 12 casing formats:

MethodExample Output`toFlatCase('Hello World!')``helloworld``toKebabCase('Hello World!')``hello-world``toCamelCase('Hello World!')``helloWorld``toPascalCase('Hello World!')``HelloWorld``toSnakeCase('Hello World!')``hello_world``toConstantCase('Hello World!')``HELLO_WORLD``toCobolCase('Hello World!')``HELLO-WORLD``toTitleCase('Hello World!')``Hello World``toDotCase('Hello World!')``hello.world``toTrainCase('Hello World!')``Hello-World``toSlug('Café & Co!')``cafe-co``toAcronym('Hello World!')``HW````
use Napse\StringUtils\StringUtils;

echo StringUtils::toKebabCase('Hello World! 123');
// Output: hello-world-123

echo StringUtils::toSlug('Über uns! 🎉');
// Output: uber-uns
```

Version
-------

[](#version)

Immutable semantic versioning value object with parsing, comparison, and modification.

### Creating Versions

[](#creating-versions)

```
use Napse\StringUtils\Version;

$version = new Version(1, 2, 3, 'beta', 'build123');
echo $version; // 1.2.3-beta+build123

$version = Version::fromString('2.1.0-beta+exp.sha.5114f85');
echo $version; // 2.1.0-beta+exp.sha.5114f85
```

### Accessing Components

[](#accessing-components)

```
$version = new Version(1, 2, 3, 'alpha', 'build123');

$version->getMajor();         // 1
$version->getMinor();         // 2
$version->getPatch();         // 3
$version->getPreRelease();    // "alpha"
$version->getBuildMetadata(); // "build123"
```

### Incrementing

[](#incrementing)

```
$version = new Version(1, 2, 3);

echo $version->incrementMajor(); // 2.0.0
echo $version->incrementMinor(); // 1.3.0
echo $version->incrementPatch(); // 1.2.4
```

### Immutable Modifications

[](#immutable-modifications)

```
$version = new Version(1, 0, 0);

echo $version->withMajor(2);              // 2.0.0
echo $version->withMinor(5);              // 1.5.0
echo $version->withPatch(9);              // 1.0.9
echo $version->withPreRelease('rc1');     // 1.0.0-rc1
echo $version->withBuildMetadata('b567'); // 1.0.0+b567
```

### Comparing

[](#comparing)

```
$v1 = new Version(1, 2, 3);
$v2 = new Version(1, 2, 4);

$v1->compare($v2); // -1 ($v1 < $v2)
$v2->compare($v1); //  1 ($v2 > $v1)

$v3 = new Version(1, 2, 3);
$v1->compare($v3); //  0 ($v1 == $v3)
```

Pre-release versions have lower precedence than the associated normal version (SemVer §11):

```
$alpha = Version::fromString('1.0.0-alpha');
$stable = new Version(1, 0, 0);

$alpha->compare($stable); // -1 (alpha < stable)
```

### Convenience Methods

[](#convenience-methods)

```
$v1 = new Version(1, 0, 0);
$v2 = new Version(2, 0, 0);

$v1->equals($v2);              // false
$v1->lessThan($v2);            // true
$v1->greaterThan($v2);         // false
$v1->lessThanOrEqual($v2);     // true
$v1->greaterThanOrEqual($v2);  // false
$v1->isStable();               // true

$beta = new Version(1, 0, 0, 'beta');
$beta->isStable();             // false
```

Emoji
-----

[](#emoji)

Terminal-friendly emoji constants for CLI output.

ConstantEmojiPurpose`CHECKMARK_OK`✅Success`CHECKMARK_NOK`❌Failure`WARNING`⚠️Warnings`INFO`ℹ️Info messages`ARROW_RIGHT`➜Lists, steps`ROCKET`🚀Start/Deploy`HOURGLASS`⏳In progress`LOCK`🔒Security/Auth`GEAR`⚙️Configuration`SPARKLE`✨Success/New```
use Napse\StringUtils\Emoji;

echo Emoji::CHECKMARK_OK . ' All tests passed';  // ✅ All tests passed
echo Emoji::WARNING . ' Config missing';          // ⚠️ Config missing
echo Emoji::ROCKET . ' Deploying...';             // 🚀 Deploying...
```

Testing
-------

[](#testing)

```
composer require --dev phpunit/phpunit
vendor/bin/phpunit
```

Static Analysis
---------------

[](#static-analysis)

```
composer require --dev phpstan/phpstan
vendor/bin/phpstan analyse
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License
-------

[](#license)

This package is licensed under the [MIT License](LICENSE).

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance75

Regular maintenance activity

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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 ~62 days

Recently: every ~86 days

Total

7

Last Release

134d ago

Major Versions

v1.5.0 → v2.0.02026-02-20

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/126022850?v=4)[TheNapse](/maintainers/TheNapse)[@TheNapse](https://github.com/TheNapse)

---

Top Contributors

[![TheNapse](https://avatars.githubusercontent.com/u/126022850?v=4)](https://github.com/TheNapse "TheNapse (12 commits)")[![SteffenSchmitt](https://avatars.githubusercontent.com/u/3513571?v=4)](https://github.com/SteffenSchmitt "SteffenSchmitt (4 commits)")

---

Tags

stringsemverutilsversioncase conversion

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.3M192](/packages/danielstjules-stringy)[nikolaposa/version

Value Object that represents a SemVer-compliant version number.

1407.3M23](/packages/nikolaposa-version)[voku/stringy

A string manipulation library with multibyte support

1863.9M26](/packages/voku-stringy)[shivas/versioning-bundle

Symfony application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recommendations

1111.3M1](/packages/shivas-versioning-bundle)[statamic/stringy

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

245.0M18](/packages/statamic-stringy)[jelix/version

Parse any version syntax, including semantic version. Compare version, using Composer version constraints syntax.

13211.0k5](/packages/jelix-version)

PHPackages © 2026

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