Advanced string manipulation utilities for PHP with comprehensive Unicode support.
The Strings component provides an object-oriented API for string manipulation, dealing with bytes, UTF-8 code points, and Unicode graphemes. It offers both static utility methods and fluent object-oriented interfaces for maximum flexibility.
- Static Utilities: Fast static methods for common string operations
- Fluent Interface: Object-oriented string manipulation with method chaining
- Unicode Support: Comprehensive Unicode string handling with normalization
- HTML Safety: HTML-aware string manipulation with proper escaping
- Inflection: Pluralization, singularization, and text transformation
- Truncation: Smart text truncation with word preservation
composer require hierone/strings
// Create a fluent string object
$result = str('Hello World')->lower()->replace(' ', '-');
// Create a Unicode string
$unicode = u('café')->normalize()->upper();
// Create an HTML-safe string
$html = html('<p>Content</p>')->escape();
use Hierone\Component\Support\Strings\Str;
$contains = Str::contains('Hello World', 'World');
$slug = Str::lower('Hello World');
$random = Str::random(16);
use Hierone\Component\Support\Strings\StringObject;
$string = new StringObject('Hello World');
$result = $string->lower()->replace(' ', '-')->toString();
use Hierone\Component\Support\Strings\UnicodeString;
$unicode = new UnicodeString('café', 'UTF-8');
$length = $unicode->graphemeLength(); // Visual character count
$normalized = $unicode->normalize('C');
$reversed = $unicode->reverse();
- PHP 8.2 or higher
hierone/depreciation-contracts
^1.0
This package is open-sourced software licensed under the MIT license.