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

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

romanlazko/str
==============

String helper functions.

1.3(11mo ago)05MITPHPPHP &gt;=8.0

Since May 24Pushed 11mo agoCompare

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

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

Str - PHP String Utilities
==========================

[](#str---php-string-utilities)

A comprehensive string manipulation library for PHP with multibyte support.

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

[](#installation)

```
composer require romanlazko/str
```

Usage
-----

[](#usage)

### Using the Str Class

[](#using-the-str-class)

```
use RomanLazko\Str\Str;

// Get string length
$length = Str::length('Hello World'); // 11

// Convert to kebab-case
$kebab = Str::kebab('fooBar'); // 'foo-bar'

// Convert to snake_case
$snake = Str::snake('fooBar'); // 'foo_bar'
// Convert to camelCase
$camel = Str::camel('foo-bar'); // 'fooBar'
// Convert to StudlyCase
$studly = Str::studly('foo_bar'); // 'FooBar'

// String manipulation
$reversed = Str::reverse('Hello'); // 'olleH'
$limited = Str::limit('This is a long string', 10); // 'This is a...'
$words = Str::words('This is a long string', 3); // 'This is a...'
```

### Using the str() Helper

[](#using-the-str-helper)

```
// Chainable string manipulation
$result = str('Hello World')
    ->upper()
    ->replace('WORLD', 'Universe')
    ->finish('!')
    ->toString();
// Result: 'HELLO UNIVERSE!'
```

Available Methods
-----------------

[](#available-methods)

### String Case Conversion

[](#string-case-conversion)

- `camel(string $string): string` - Convert to camelCase
- `kebab(string $string): string` - Convert to kebab-case
- `snake(string $string, string $delimiter = '_'): string` - Convert to snake\_case
- `studly(string $string): string` - Convert to StudlyCase
- `title(string $string): string` - Convert to Title Case
- `ucfirst(string $string): string` - Make first character uppercase
- `lcfirst(string $string): string` - Make first character lowercase
- `upper(string $string): string` - Convert to uppercase
- `lower(string $string): string` - Convert to lowercase

### String Manipulation

[](#string-manipulation)

- `length(string $string, ?string $encoding = 'UTF-8'): int` - Get string length
- `limit(string $string, int $limit = 100, string $end = '...'): string` - Limit string length
- `words(string $string, int $words = 100, string $end = '...'): string` - Limit number of words
- `reverse(string $string): string` - Reverse the string
- `replace(string $string, string|array $search, string|array $replace, int $count = null): string` - Replace text
- `repeat(string $string, int $times): string` - Repeat string
- `slug(string $string, string $separator = '-'): string` - Generate URL-friendly slug
- `substr(string $string, int $start, ?int $length = null, string $encoding = 'UTF-8'): string` - Get substring
- `substrCount(string $string, string $needle): int` - Count substring occurrences
- `substrReplace(string $string, string $replace, int $offset = 0, ?int $length = null): string` - Replace text within portion of string
- `trim(string $string, string $charlist = " \t\n\r\v\0"): string` - Strip whitespace from beginning and end
- `ltrim(string $string, string $charlist = " \t\n\r\v\0"): string` - Strip whitespace from beginning
- `rtrim(string $string, string $charlist = " \t\n\r\v\0"): string` - Strip whitespace from end
- `start(string $string, string $cap): string` - Add string to start if not present
- `finish(string $string, string $cap): string` - Add string to end if not present

### String Checks

[](#string-checks)

- `contains(string $string, string $needle): bool` - Check if string contains substring
- `is(string $pattern, string $value): bool` - Check if string matches pattern
- `startsWith(string $string, string $needle): bool` - Check if string starts with substring
- `endsWith(string $string, string $needle): bool` - Check if string ends with substring
- `isAscii(string $string): bool` - Check if string is ASCII
- `isUuid(string $string): bool` - Check if string is a valid UUID

### Helper Methods

[](#helper-methods)

- `str($string = null)` - Create a chainable string instance ```
    $result = str('hello')->upper()->finish('!'); // 'HELLO!'
    ```

License
-------

[](#license)

This package is open-source software licensed under the [MIT license](LICENSE).

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

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance50

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

4

Last Release

359d ago

### Community

Maintainers

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

---

Top Contributors

[![romanlazko](https://avatars.githubusercontent.com/u/43849612?v=4)](https://github.com/romanlazko "romanlazko (6 commits)")

### Embed Badge

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

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

PHPackages © 2026

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