navarr / smartstring
一个可以智能判断是否使用grapheme_*或以字节为中心的字符串函数的对象
v0.1.0
2022-03-07 02:05 UTC
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-08-29 16:50:40 UTC
README
SmartString是一个库,它可以自动判断文本字符串是否可以使用PHP的字节操作工具,或者是否需要升级以使用Grapheme操作,以便您能够尽可能快和准确地处理文本。
安装
composer require navarr/smartstring
使用
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