navarr/smartstring

An object that can intelligently determine whether to use grapheme_* or byte-focused string functions

Fund package maintenance!
navarr

Installs: 4

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/navarr/smartstring

v0.2.1 2025-10-06 20:44 UTC

This package is auto-updated.

Last update: 2025-10-06 20:45:34 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