PHPackages                             marjovanlier/stringmanipulation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. marjovanlier/stringmanipulation

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

marjovanlier/stringmanipulation
===============================

High-performance PHP 8.3+ string manipulation library featuring O(n) algorithms with up to 5x speed improvements. Provides Unicode-aware operations including searchWords(), nameFix(), utf8Ansi(), removeAccents(), and isValidDate() with comprehensive testing infrastructure.

v2.0.13(3mo ago)083111MITPHPPHP ^8.3CI passing

Since Jan 5Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/MarjovanLier/StringManipulation)[ Packagist](https://packagist.org/packages/marjovanlier/stringmanipulation)[ Docs](https://github.com/marjovanlier/stringmanipulation)[ RSS](/packages/marjovanlier-stringmanipulation/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (15)Versions (100)Used By (1)

String Manipulation Library for PHP
===================================

[](#string-manipulation-library-for-php)

Table of Contents
-----------------

[](#table-of-contents)

- [Introduction](#introduction)
- [Features](#features)
- [Performance Benchmarks](#performance-benchmarks)
- [Installation](#installation)
- [Usage](#usage)
- [Advanced Usage](#advanced-usage)
- [Testing &amp; Quality Assurance](#testing--quality-assurance)
- [System Requirements](#system-requirements)
- [Contributing](#contributing)
- [Support](#support)

Introduction
------------

[](#introduction)

Welcome to the `StringManipulation` library, a high-performance PHP 8.3+ toolkit designed for complex and efficient string handling. Following a recent suite of O(n) optimisations, the library is now **2-5x faster**, making it one of the most powerful and reliable solutions for developers who require speed and precision in their PHP applications.

This library specialises in Unicode handling, data normalisation, encoding conversion, and validation with comprehensive testing and quality assurance.

[![Packagist Version](https://camo.githubusercontent.com/24ecc4053393904f900265aeff56187fcee7a8a6e7112d36ee7c2413e1bee381/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61726a6f76616e6c6965722f737472696e676d616e6970756c6174696f6e)](https://packagist.org/packages/marjovanlier/stringmanipulation)[![Packagist Downloads](https://camo.githubusercontent.com/c24275abeff31773dd4b52ed408ca140d6979ce93e4c2bbfac3f4d757bb7f5be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61726a6f76616e6c6965722f737472696e676d616e6970756c6174696f6e)](https://packagist.org/packages/marjovanlier/stringmanipulation)[![Packagist License](https://camo.githubusercontent.com/de2b336d6aad50c447ff61dbc0ed4da8df73f7fa7eff5f6f2788d02e694b0666/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d61726a6f76616e6c6965722f737472696e676d616e6970756c6174696f6e)](https://choosealicense.com/licenses/mit/)[![PHP from Packagist](https://camo.githubusercontent.com/321b2df8585f5a2bf3d879ff3fd8e1633aa08ba9ec7a7874af327f8c8f0ea545/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d61726a6f76616e6c6965722f737472696e676d616e6970756c6174696f6e)](https://packagist.org/packages/marjovanlier/stringmanipulation)[![Latest Stable](https://camo.githubusercontent.com/ddc75f28c4f894ad6d945d4c847f4a7bfd83094e652f920ddc156e32b7075973/68747470733a2f2f706f7365722e707567782e6f72672f6d61726a6f76616e6c6965722f737472696e676d616e6970756c6174696f6e2f762f737461626c65)](https://packagist.org/packages/marjovanlier/stringmanipulation)[![PHPStan Enabled](https://camo.githubusercontent.com/441b5874ce4df0a2defc892979c96c46889b69cb32119d04f0b48626349f8bc9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d627269676874677265656e2e7376673f7374796c653d666c6174)](https://phpstan.org/)[![Phan Enabled](https://camo.githubusercontent.com/8699a17ab32994242c2292ad208953ca3085568adea1123f59d4c0c86ecf5d12/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5068616e2d656e61626c65642d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/phan/phan/)[![Psalm Enabled](https://camo.githubusercontent.com/ad56256f9a08d2b16ff1ca8828e27b8153bbccfd0e49d3b247e5ae615199e799/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5073616c6d2d656e61626c65642d627269676874677265656e2e7376673f7374796c653d666c6174)](https://psalm.dev/)[![codecov](https://camo.githubusercontent.com/0acd16e471b860d1c8db4c9117e6400172c5d44267f0fa0f3f7e512b9fb99351/68747470733a2f2f636f6465636f762e696f2f6769746875622f4d61726a6f76616e4c6965722f537472696e674d616e6970756c6174696f6e2f67726170682f62616467652e7376673f746f6b656e3d6c425470576c53713337)](https://codecov.io/github/MarjovanLier/StringManipulation)

Features
--------

[](#features)

- **`removeAccents()`**: Efficiently strips accents and diacritics to normalise text. Powered by O(n) optimisations using hash table lookups, this high-performance feature makes text comparison and searching faster than ever (981,436+ ops/sec).
- **`searchWords()`**: Transforms strings into a search-optimised format ideal for database queries. This high-performance function intelligently removes irrelevant characters and applies single-pass algorithms to improve search accuracy (387,231+ ops/sec).
- **`nameFix()`**: Standardises names by capitalising letters and correctly handling complex prefixes. Its performance-oriented design with consolidated regex operations ensures consistent data formatting at scale (246,197+ ops/sec).
- **`utf8Ansi()`**: Convert UTF-8 encoded characters to their ANSI equivalents with comprehensive Unicode mappings, facilitating compatibility with legacy systems.
- **`isValidDate()`**: Comprehensive date validation utility that ensures date strings conform to specified formats and validates logical consistency.
- **Comprehensive Unicode/UTF-8 Support**: Built from the ground up to handle a wide range of international characters with optimised character mappings, ensuring your application is ready for a global audience.

Performance Benchmarks
----------------------

[](#performance-benchmarks)

The library has undergone extensive performance tuning, resulting in **2-5x speed improvements** through O(n) optimisation algorithms. Our benchmarks demonstrate the library's capability to handle high-volume data processing efficiently:

MethodPerformanceOptimisation Technique`removeAccents()`**981,436+ ops/sec**Hash table lookups with strtr()`searchWords()`**387,231+ ops/sec**Single-pass combined mapping`nameFix()`**246,197+ ops/sec**Consolidated regex operations*Benchmarks measured on standard development environments. Actual performance may vary based on hardware, string length, and complexity.*

**Key Optimisation Features:**

- O(n) complexity algorithms for all core methods
- Static caching for character mapping tables
- Single-pass string transformations
- Minimal memory allocation in critical paths

Installation
------------

[](#installation)

Install the package via Composer with the following command:

```
composer require marjovanlier/stringmanipulation
```

Usage
-----

[](#usage)

For more detailed examples of each feature, please refer to the corresponding sections below.

```
use MarjovanLier\StringManipulation\StringManipulation;

$result = StringManipulation::searchWords('Hello_World');
echo $result; // Outputs: 'hello world'
```

License
-------

[](#license)

This library is licensed under the MIT License. For more information, please refer to the [License File](LICENSE).

Detailed Examples
-----------------

[](#detailed-examples)

### Name Standardisation

[](#name-standardisation)

- **Case Conversion**: Easily convert strings between upper case, lower case, and title case, allowing for flexible text formatting and presentation. For example, converting 'john doe' to 'John Doe' for proper name presentation.

```
use MarjovanLier\StringManipulation\StringManipulation;

$fixedName = StringManipulation::nameFix('mcdonald');
echo $fixedName; // Outputs: 'McDonald'
```

### Search Words

[](#search-words)

This feature optimises strings for database queries by removing unnecessary characters and optimising for search engine algorithms.

```
use MarjovanLier\StringManipulation\StringManipulation;

$result = StringManipulation::searchWords('Hello_World');
echo $result; // Outputs: 'hello world'
```

### Name Fix

[](#name-fix)

Standardise last names by capitalising the first letter of each part of the name and handling prefixes correctly.

```
use MarjovanLier\StringManipulation\StringManipulation;

$fixedName = StringManipulation::nameFix('de souza');
echo $fixedName; // Outputs: 'De Souza'
```

### UTF-8 to ANSI Conversion

[](#utf-8-to-ansi-conversion)

Convert UTF-8 encoded characters to their ANSI equivalents, facilitating compatibility with systems that do not support UTF-8.

```
use MarjovanLier\StringManipulation\StringManipulation;

$ansiString = StringManipulation::utf8Ansi('Über');
echo $ansiString; // Outputs: 'Uber'
```

### Remove Accents

[](#remove-accents)

Strip accents and special characters from strings to normalise text, making it easier to search and compare.

```
use MarjovanLier\StringManipulation\StringManipulation;

$normalisedString = StringManipulation::removeAccents('Crème Brûlée');
echo $normalisedString; // Outputs: 'Creme Brulee'
```

### Date Validation

[](#date-validation)

Ensure date strings conform to specified formats and check for logical consistency, such as correct days in a month.

```
use MarjovanLier\StringManipulation\StringManipulation;

$isValidDate = StringManipulation::isValidDate('2023-02-29', 'Y-m-d');
echo $isValidDate ? 'Valid' : 'Invalid'; // Outputs: 'Invalid'
```

Advanced Usage
--------------

[](#advanced-usage)

For more complex string manipulations, consider chaining functions to achieve unique transformations. For instance, you could first normalise a string, apply a search optimisation, and finally standardise the casing for a comprehensive text processing example.

```
use MarjovanLier\StringManipulation\StringManipulation;

$originalString = 'Crème Brûlée';
$processedString = StringManipulation::nameFix(StringManipulation::utf8Ansi(StringManipulation::removeAccents($originalString)));
echo $processedString; // Outputs: 'Creme Brulee'
```

This approach allows for flexible and powerful string manipulations by combining the library's functions to suit your specific needs.

Contributing
------------

[](#contributing)

We welcome contributions to the `StringManipulation` library! If you're interested in helping, please follow these steps:

1. Fork the repository and create your feature branch.
2. Ensure your changes adhere to our coding standards and include tests if applicable.
3. Submit a pull request with a detailed description of your changes.

Thank you for your interest in improving our library!

Testing &amp; Quality Assurance
-------------------------------

[](#testing--quality-assurance)

We are committed to delivering reliable, high-quality code. Our library is rigorously tested using a comprehensive suite of tools to ensure stability and correctness.

### Docker-Based Testing (Recommended)

[](#docker-based-testing-recommended)

For a consistent and reliable testing environment, we recommend using Docker. Our Docker setup includes PHP 8.3 with all required extensions:

```
# Run complete test suite
docker-compose run --rm test-all

# Run individual test suites
docker-compose run --rm test-phpunit      # PHPUnit tests
docker-compose run --rm test-phpstan      # Static analysis
docker-compose run --rm test-code-style   # Code style
docker-compose run --rm test-infection    # Mutation testing
```

### Local Testing

[](#local-testing)

If you have a local PHP 8.3+ environment configured:

```
# Complete test suite
composer tests

# Individual tests
./vendor/bin/phpunit --filter testClassName
./vendor/bin/phpunit --filter '/::testMethodName$/'
```

### Our Quality Suite Includes:

[](#our-quality-suite-includes)

- **PHPUnit**: 166 comprehensive tests with 100% code coverage ensuring functional correctness
- **Mutation Testing**: 88% Mutation Score Indicator (MSI) with Infection, guaranteeing our tests are robust and meaningful
- **Static Analysis**: Proactive bug detection using:
    - PHPStan (level max, strict rules)
    - Psalm (level 1, 99.95% type coverage)
    - Phan (clean analysis results)
    - PHPMD (mess detection)
- **Code Style**: Automated formatting with Laravel Pint (PSR compliance)
- **Performance Benchmarks**: Continuous performance monitoring with comprehensive benchmarking suite

System Requirements
-------------------

[](#system-requirements)

- **PHP 8.3 or later** (strict typing enabled)
- **`mbstring` extension** for multi-byte string operations
- **`intl` extension** for internationalisation and advanced Unicode support
- **Enabled `declare(strict_types=1);`** for robust type safety
- **Composer** for package management

Support
-------

[](#support)

For support, please open an issue on our [GitHub repository](https://github.com/MarjovanLier/StringManipulation/issues).

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance81

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 99.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~8 days

Recently: every ~24 days

Total

99

Last Release

101d ago

Major Versions

v1.0.85 → v2.0.12025-02-12

PHP version history (4 changes)v1.0.0PHP ^8.2

v1.0.81PHP &gt;=8.2.0|&gt;=8.3.0|&gt;=8.4.0

v1.0.85PHP &gt;=8.3.0|&gt;=8.4.0

v2.0.9PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/f9520b2d51b78f87c91816877be56013551a9ad34ed9b0a002465b22cd36892f?d=identicon)[MarjovanLier](/maintainers/MarjovanLier)

---

Top Contributors

[![MarjovanLier](https://avatars.githubusercontent.com/u/2212059?v=4)](https://github.com/MarjovanLier "MarjovanLier (178 commits)")[![sweep-ai-deprecated[bot]](https://avatars.githubusercontent.com/in/307814?v=4)](https://github.com/sweep-ai-deprecated[bot] "sweep-ai-deprecated[bot] (1 commits)")

---

Tags

ansicharacter-encodingdate-validationphpphp-librarystring-manipulationtext-processingunicodevalidationunicodeperformanceencodingstring manipulation

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/marjovanlier-stringmanipulation/health.svg)

```
[![Health](https://phpackages.com/badges/marjovanlier-stringmanipulation/health.svg)](https://phpackages.com/packages/marjovanlier-stringmanipulation)
```

###  Alternatives

[composer/semver

Version comparison library that offers utilities, version constraint parsing and validation.

3.3k489.6M672](/packages/composer-semver)[giggsey/libphonenumber-for-php

A library for parsing, formatting, storing and validating international phone numbers, a PHP Port of Google's libphonenumber.

5.0k148.7M416](/packages/giggsey-libphonenumber-for-php)[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M107](/packages/propaganistas-laravel-phone)[opis/json-schema

Json Schema Validator for PHP

64236.9M186](/packages/opis-json-schema)[giggsey/libphonenumber-for-php-lite

A lite version of giggsey/libphonenumber-for-php, which is a PHP Port of Google's libphonenumber

8412.9M47](/packages/giggsey-libphonenumber-for-php-lite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
