PHPackages                             duanyong/component-core-stringutils - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. duanyong/component-core-stringutils

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

duanyong/component-core-stringutils
===================================

Offers operations on the data type string as a PHP component.

v0.4.0(12y ago)023[1 issues](https://github.com/duanyong/StringUtils/issues)LGPL-3.0+PHPPHP &gt;=5.3.3

Since Sep 27Pushed 8y ago1 watchersCompare

[ Source](https://github.com/duanyong/StringUtils)[ Packagist](https://packagist.org/packages/duanyong/component-core-stringutils)[ Docs](http://github.com/FlorianWolters/PHP-Component-Core-StringUtils)[ RSS](/packages/duanyong-component-core-stringutils/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (8)Versions (6)Used By (0)

Component\\Core\\StringUtils
============================

[](#componentcorestringutils)

**Component\\Core\\StringUtils** is a simple-to-use [PHP](https://php.net "PHP: Hypertext Preprocessor") component that provides operations on the data type `string`.

[![Build Status](https://camo.githubusercontent.com/ab002af858bdee49aa72a0c8865e3d4a1e0a360ac48dbc5da4695a78a9a9f66a/68747470733a2f2f7472617669732d63692e6f72672f466c6f7269616e576f6c746572732f5048502d436f6d706f6e656e742d436f72652d537472696e675574696c732e737667)](https://travis-ci.org/FlorianWolters/PHP-Component-Core-StringUtils)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/4e582dc8b1e6110a5712466e4d1269a68a97c08eab26f7ecf9bf0cb8a38ff53e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f466c6f7269616e576f6c746572732f5048502d436f6d706f6e656e742d436f72652d537472696e675574696c732f6261646765732f7175616c6974792d73636f72652e706e673f733d30373434616431626166643532323132613136313161303039666261353163333065343332363966)](https://scrutinizer-ci.com/g/FlorianWolters/PHP-Component-Core-StringUtils/)[![Code Coverage](https://camo.githubusercontent.com/9e401031e02cbb5188d700987b54c165f0c7139f0a067ba2cae1ccee8a231429/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f466c6f7269616e576f6c746572732f5048502d436f6d706f6e656e742d436f72652d537472696e675574696c732f6261646765732f636f7665726167652e706e673f733d39393463393231336438326565616464336563643835313661383764333063643935653037373731)](https://scrutinizer-ci.com/g/FlorianWolters/PHP-Component-Core-StringUtils/)[![SensioLabsInsight](https://camo.githubusercontent.com/18f83deef78b8e204c48f30705cd9708e442603a9959884c457266d6c1d70c78/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f32663330366462322d633761312d343134362d393938642d6339326365656337353134652f6d696e692e706e67)](https://insight.sensiolabs.com/projects/2f306db2-c7a1-4146-998d-c92ceec7514e)[![Coverage Status](https://camo.githubusercontent.com/2ae26457bde15f19294113ca33244a73190074d169b895781e896c2e6df6e737/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f466c6f7269616e576f6c746572732f5048502d436f6d706f6e656e742d436f72652d537472696e675574696c732f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/FlorianWolters/PHP-Component-Core-StringUtils?branch=master)

[![Latest Stable Version](https://camo.githubusercontent.com/5d6da3211c26f526d93a5fe1b410c94b15edd03d2887226b210742f077d5f0b2/68747470733a2f2f706f7365722e707567782e6f72672f666c6f7269616e776f6c746572732f636f6d706f6e656e742d636f72652d737472696e677574696c732f762f737461626c652e706e67)](https://packagist.org/packages/florianwolters/component-core-stringutils)[![Total Downloads](https://camo.githubusercontent.com/9e0b50dc7105884acf3138cde7e0578b4f4f2e77dd48af3f025575016d391a11/68747470733a2f2f706f7365722e707567782e6f72672f666c6f7269616e776f6c746572732f636f6d706f6e656e742d636f72652d737472696e677574696c732f646f776e6c6f6164732e706e67)](https://packagist.org/packages/florianwolters/component-core-stringutils)[![Monthly Downloads](https://camo.githubusercontent.com/e7d587a2dfc0b7883e1dc99b6372a3a930fda0cd7005739789759f261ab7ba58/68747470733a2f2f706f7365722e707567782e6f72672f666c6f7269616e776f6c746572732f636f6d706f6e656e742d636f72652d737472696e677574696c732f642f6d6f6e74686c792e706e67)](https://packagist.org/packages/florianwolters/component-core-stringutils)[![Daily Downloads](https://camo.githubusercontent.com/bdbf3c06ac05ea31ce27c245579f2349885405b4485a179e29647a9808b694ed/68747470733a2f2f706f7365722e707567782e6f72672f666c6f7269616e776f6c746572732f636f6d706f6e656e742d636f72652d737472696e677574696c732f642f6461696c792e706e67)](https://packagist.org/packages/florianwolters/component-core-stringutils)[![Latest Unstable Version](https://camo.githubusercontent.com/6d02cff3484e13df940e122e56eefb07ab873132ce28868959e1492700ea43f4/68747470733a2f2f706f7365722e707567782e6f72672f666c6f7269616e776f6c746572732f636f6d706f6e656e742d636f72652d737472696e677574696c732f762f756e737461626c652e706e67)](https://packagist.org/packages/florianwolters/component-core-stringutils)[![License](https://camo.githubusercontent.com/89998b0f8a45a5f652b5db5326428a029822abe174320659e5e98522d0e1e191/68747470733a2f2f706f7365722e707567782e6f72672f666c6f7269616e776f6c746572732f636f6d706f6e656e742d636f72652d737472696e677574696c732f6c6963656e73652e706e67)](https://packagist.org/packages/florianwolters/component-core-stringutils)

[![Stories in Ready](https://camo.githubusercontent.com/30d3feb81a72f49e4f46db7b1841d9a44be4e518d94f0c3f9d23322da86b4120/68747470733a2f2f62616467652e776166666c652e696f2f666c6f7269616e776f6c746572732f7068702d636f6d706f6e656e742d636f72652d737472696e677574696c732e706e673f6c6162656c3d7265616479267469746c653d5265616479)](https://waffle.io/florianwolters/php-component-core-stringutils)[![Dependency Status](https://camo.githubusercontent.com/09e43bfb13c14831299c23990243e8544ae7608fb3250dc4c74828013cd5df36/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3531633333313034303037666364303030323030303433632f62616467652e706e67)](https://www.versioneye.com/user/projects/51c33104007fcd000200043c)[![Dependencies Status](https://camo.githubusercontent.com/b87e84ee31c3bcac08bc6e4b7b276803382300abd3b08355ce1e90e995351463/68747470733a2f2f646570656e64696e672e696e2f466c6f7269616e576f6c746572732f5048502d436f6d706f6e656e742d436f72652d537472696e675574696c732e706e67)](http://depending.in/FlorianWolters/PHP-Component-Core-StringUtils)[![HHVM Status](https://camo.githubusercontent.com/d6c1b501749c221531b5ad3b9403e6e42703f7186cc07528f3f56eebaa08eb4a/687474703a2f2f6868766d2e683463632e64652f62616467652f666c6f7269616e776f6c746572732f636f6d706f6e656e742d636f72652d737472696e677574696c732e706e67)](http://hhvm.h4cc.de/package/florianwolters/component-core-stringutils)

Table of Contents (ToC)
-----------------------

[](#table-of-contents-toc)

- [Introduction](#introduction)
- [Features](#features)
- [Requirements](#requirements)
- [Usage](#usage)
- [Installation](#installation)
- [Testing](#testing)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

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

[](#introduction)

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

[](#introduction-1)

The [string functions](https://php.net/ref.strings "PHP: String Functions") of the [PHP](https://php.net "PHP: Hypertext Preprocessor") scripting language are not consistent:

- Some function names begin with `str`, e. g. `strpos`.
- Some function names begin with `str_`, e. g. `str_rot13`.
- Some function names **do not** begin with `str`, e. g. `trim` and `substr`.

Quite a lot of the built-in string functions are only *Wrapper Functions* for the string functions of the underlying C programming language. Therefore a lot of useful string functions are not included in the [PHP](https://php.net "PHP: Hypertext Preprocessor") standard library.

**Component\\Core\\StringUtils** offers static classes that offer operations on the data type `string`. The goal of this project is to create an unified and simplified Application Programming Interface (API) for string functions to use in the [PHP](https://php.net "PHP: Hypertext Preprocessor") scripting language.

This project is inspired by the following Java classes from the [Apache Commons Lang Application Programming Interface (API)](https://commons.apache.org/lang "Commons Lang"):

- [StringUtils](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html "StringUtils (Commons Lang 3 API)")
- [WordUtils](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/text/WordUtils.html "WordUtils (Commons Lang 3 API)")
- [CharUtils](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/CharUtils.html "CharUtils (Commons Lang 3 API)")
- [RandomStringUtils](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/RandomStringUtils.html "RandomStringUtils (Commons Lang 3 API)")

The implementation has been adapted and abstracted for [PHP](https://php.net "PHP: Hypertext Preprocessor").

Features
--------

[](#features)

- The class [`StringUtils`](src/main/php/StringUtils.php "FlorianWolters\Component\Core\StringUtils") offers operations (currently **39** methods) on the data type `string`.
- The class [`WordUtils`](src/main/php/WordUtils.php "FlorianWolters\Component\Core\WordUtils") offers operations (currently **7** methods) on the data type `string` that contain words.
- The class [`CharUtils`](src/main/php/CharUtils.php "FlorianWolters\Component\Core\CharUtils") offers operations (currently **18** methods) on characters.
- The class [`RandomStringUtils`](src/main/php/RandomStringUtils.php "FlorianWolters\Component\Core\RandomStringUtils") offers operations (currently **7**methods) for random `string`s.
- Artifacts tested with both static and dynamic test procedures:
    - Dynamic component tests (unit and integration tests) implemented with [PHPUnit](https://phpunit.de "PHPUnit").
    - Static code analysis performed using the following tools:
        - [PHP\_CodeSniffer](https://pear.php.net/package/PHP_CodeSniffer "PHP_CodeSniffer"): Style Checker
        - [PHP Mess Detector (PHPMD)](http://phpmd.org "PHPMD - PHP Mess Detector"): Code Analyzer
        - [PHP Depend](http://pdepend.org "PHP Depend - Software Metrics for PHP"): Code Metrics
        - [phpcpd](https://github.com/sebastianbergmann/phpcpd "sebastianbergmann/phpcpd · GitHub"): Copy/Paste Detector (CPD)
        - [phpdcd](https://github.com/sebastianbergmann/phpdcd "sebastianbergmann/phpdcd · GitHub"): Dead Code Detector (DCD)
        - [SensioLabs Security Checker](https://github.com/sensiolabs/security-checker "SensioLabs Security Checker"): Security Checker
    - Continuous Integration (CI) using the following web services:
        - [Scrutinizer CI](https://scrutinizer-ci.com "Scrutinizer CI")
        - [SensioLabsInsight](https://insight.sensiolabs.com "SensioLabsInsight")
        - [Coveralls](https://coveralls.io "Coveralls")
        - [VersionEye](https://versioneye.com "VersionEye")
        - [Depending](https://depending.in "Depending")
        - [Waffle](https://waffle.io "Waffle")
- Provides a [Packagist](https://packagist.org "Packagist") package which can be installed using the dependency manager [Composer](https://getcomposer.org "Composer"). Click [here](https://packagist.org/packages/florianwolters/component-core-stringutils "florianwolters/component-core-stringutils - Packagist") for the package on [Packagist](https://packagist.org "Packagist").
- Provides a complete Application Programming Interface (API) documentation generated with the documentation generator [Sami](https://github.com/fabpot/sami "fabpot/sami · GitHub"). Click [here](http://blog.florianwolters.de/PHP-Component-Core-StringUtils "Application Programming Interface (API) documentation") for the API documentation.
- Follows the following "standards" from the [PHP Framework Interoperability Group (FIG)](http://php-fig.org "PHP-FIG — PHP Framework Interop Group"). PSR stands for PHP Standards Recommendation:
    - [PSR-0](http://php-fig.org/psr/psr-0 "PSR-0 requirements for autoloader interoperability"): Autoloading Standards

        > Aims to provide a standard file, class and namespace convention to allow plug-and-play code.
    - [PSR-1](http://php-fig.org/psr/psr-1 "PSR-1 basic coding style guide"): Basic Coding Standard

        > Aims to ensure a high level of technical interoperability between shared PHP code.
    - [PSR-2](http://php-fig.org/psr/psr-2 "PSR-2 coding style guide"): Coding Style Guide

        > Provides a Coding Style Guide for projects looking to standardize their code.
    - [PSR-4](http://php-fig.org/psr/psr-4 "PSR-4: Improved Autoloading"): Autoloader

        > A more modern take on autoloading reflecting advances in the ecosystem.
- Follows the [Semantic Versioning](http://semver.org "Semantic Versioning") (SemVer) specification version 2.0.0.

Requirements
------------

[](#requirements)

### Production

[](#production)

- [PHP](https://php.net "PHP: Hypertext Preprocessor") &gt;= 5.3.3
- [Composer](https://getcomposer.org "Composer")

### Development

[](#development)

- [PHPUnit](https://phpunit.de "PHPUnit")
- [phpcpd](https://github.com/sebastianbergmann/phpcpd "sebastianbergmann/phpcpd · GitHub")
- [phpdcd](https://github.com/sebastianbergmann/phpdcd "sebastianbergmann/phpdcd · GitHub")
- [PHP\_CodeSniffer](https://pear.php.net/package/PHP_CodeSniffer "PHP_CodeSniffer")
- [PHP Mess Detector (PHPMD)](http://phpmd.org "PHPMD - PHP Mess Detector")
- [Sami](https://github.com/fabpot/sami "fabpot/sami · GitHub")
- [SensioLabs Security Checker](https://github.com/sensiolabs/security-checker "SensioLabs Security Checker")
- [php-coveralls](https://github.com/satooshi/php-coveralls "satooshi/php-coveralls · GitHub")

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

[](#installation)

**Component\\Util\\Singleton** should be installed using the dependency manager [Composer](https://getcomposer.org "Composer").

> [Composer](https://getcomposer.org "Composer") is a tool for dependency management in [PHP](https://php.net "PHP: Hypertext Preprocessor"). It allows you to declare the dependent libraries your project needs and it will install them in your project for you.

The [Composer](https://getcomposer.org "Composer") installer can be downloaded with `php`.

```
php -r "readfile('https://getcomposer.org/installer');" | php

```

> This will just check a few [PHP](https://php.net "PHP: Hypertext Preprocessor") settings and then download `composer.phar`to your working directory. This file is the [Composer](https://getcomposer.org "Composer") binary. It is a PHAR ([PHP](https://php.net "PHP: Hypertext Preprocessor") archive), which is an archive format for [PHP](https://php.net "PHP: Hypertext Preprocessor") which can be run on the command line, amongst other things.

> To resolve and download dependencies, run the `install` command:

```
php composer.phar install

```

If you are creating a component that relies on **Component\\Util\\Singleton**, please make sure that you add **Component\\Util\\Singleton** to your component's `composer.json` file:

```
{
    "require": {
        "duanyong/component-core-stringutils": "0.4.*"
    }
}
```

Usage
-----

[](#usage)

The best documentation for **Component\\Core\\StringUtils** are the unit tests, which are shipped in the package.

**Component\\Core\\StringUtils** contains *static classes* only. Therefore instances of the classes can **not** be constructed.

Instead, the classes should be used as:

```
StringUtils::trim(' foo ');
WordUtils::wrap('foo bar', 20);
```

Testing
-------

[](#testing)

```
phpunit

```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Florian Wolters](https://github.com/FlorianWolters "FlorianWolters · GitHub")
- [All Contributors](https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/contributors "Contributors to FlorianWolters/PHP-Component-Core-StringUtils")

License
-------

[](#license)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see .

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~145 days

Total

5

Last Release

4395d ago

PHP version history (3 changes)v0.1.0-betaPHP &gt;=5.3.0

v0.2.0-betaPHP &gt;=5.3

v0.4.0PHP &gt;=5.3.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ecae192241de48a23b80147015521e81bd20eccbd12ca638bcafec4baa10ffd?d=identicon)[duanyong](/maintainers/duanyong)

---

Top Contributors

[![FlorianWolters](https://avatars.githubusercontent.com/u/1318837?v=4)](https://github.com/FlorianWolters "FlorianWolters (51 commits)")

---

Tags

helperstringlanguagewrapper

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/duanyong-component-core-stringutils/health.svg)

```
[![Health](https://phpackages.com/badges/duanyong-component-core-stringutils/health.svg)](https://phpackages.com/packages/duanyong-component-core-stringutils)
```

###  Alternatives

[samrap/acf-fluent

A fluent interface for the Advanced Custom Fields WordPress plugin

28656.0k4](/packages/samrap-acf-fluent)[bocharsky-bw/arrayzy

A native PHP arrays easy manipulation library in OOP way.

38425.4k](/packages/bocharsky-bw-arrayzy)[patrickschur/stanford-nlp-tagger

PHP wrapper for the Stanford Natural Language Processing library. Supports POSTagger and CRFClassifier.

7426.7k1](/packages/patrickschur-stanford-nlp-tagger)[clausnz/php-helpers

A Collection of useful php helper functions.

388.7k](/packages/clausnz-php-helpers)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2516.7k](/packages/iteks-laravel-enum)

PHPackages © 2026

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