bentools/violin

A multibyte string manipulation library focused on performance.

dev-master / 1.0.x-dev 2019-05-07 14:37 UTC

This package is auto-updated.

Last update: 2024-11-08 03:40:45 UTC


README

Latest Stable Version License Build Status Coverage Status Quality Score Total Downloads

Violin 🎻

Violin is a multibyte-compliant, OOP string manipulation library.

It is heavily inspired by Stringy, with a main focus on performance: when dealing with thousands of strings, it is sometimes counter-productive to rely on mb_* functions, which perform up to 4 times slower than normal str_* functions, when you manipulate ASCII strings.

Violin will detect the string's encoding, then decide wether or not to use the mbstring extension (or the Symfony polyfill if the extension is not loaded).

Installation

PHP 7.1+ is required.

composer require bentools/violin 1.0.x-dev

Tests

./vendor/bin/phpunit

Usage

use BenTools\Violin\Violin;

$str = 'fòöbàř     🤗';
print Violin::tune($str)
        ->toUpperCase()
        ->ensureLeft('Welcome ')
        ->collapseWhitespace(); // Welcome FÒÖBÀŘ 🤗

License

MIT