navarr / smartstring
An object that can intelligently determine whether to use grapheme_* or byte-focused string functions
Fund package maintenance!
navarr
Requires
- php: ^8.1
Requires (Dev)
- infection/infection: ^0.26.0
- jetbrains/phpstorm-attributes: ^1
- phpstan/phpstan: ^1
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^3.6
This package is auto-updated.
Last update: 2024-10-29 17:13:55 UTC
README
SmartString is a library that automatically determines whether a string of text can use PHP's byte manipulation tools, or if it needs to be upgraded to use Grapheme manipulations - allowing you to process text as quickly and as accurately as possible.
Installation
composer require navarr/smartstring
Usage
use Navarr\SmartString\SmartStringFactory; use Navarr\SmartString\SmartString; // Factory Methodology $factory = new SmartStringFactory(); $example = $factory->create('🏴'); echo $example->strlen(); // 1 // Singleton Methodology $example = SmartString::build('Test'); echo $example->strlen(); // 4