florianwolters / component-core-stringutils
Offers operations on the data type string as a PHP component.
Installs: 193 437
Dependents: 6
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 5
Open Issues: 0
Requires
- php: >=5.3.3
Requires (Dev)
- pdepend/pdepend: 2.0.*@dev
- phpdocumentor/phpdocumentor: 2.*
- phpmd/phpmd: 2.0.*@dev
- phpunit/phpunit: 4.1.*
- satooshi/php-coveralls: dev-master
- sebastian/phpcpd: 2.0.*
- sebastian/phpdcd: 1.0.*
- squizlabs/php_codesniffer: 2.0.*@dev
This package is not auto-updated.
Last update: 2024-12-21 14:32:39 UTC
README
Component\Core\StringUtils is a simple-to-use PHP component that
provides operations on the data type string
.
Table of Contents (ToC)
Introduction
Introduction
The string functions of the PHP 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
andsubstr
.
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 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 scripting language.
This project is inspired by the following Java classes from the Apache Commons Lang Application Programming Interface (API):
The implementation has been adapted and abstracted for PHP.
Features
- The class
StringUtils
offers operations (currently 39 methods) on the data typestring
. - The class
WordUtils
offers operations (currently 7 methods) on the data typestring
that contain words. - The class
CharUtils
offers operations (currently 18 methods) on characters. - The class
RandomStringUtils
offers operations (currently 7 methods) for randomstring
s. - Artifacts tested with both static and dynamic test procedures:
- Dynamic component tests (unit and integration tests) implemented with PHPUnit.
- Static code analysis performed using the following tools:
- PHP_CodeSniffer: Style Checker
- PHP Mess Detector (PHPMD): Code Analyzer
- PHP Depend: Code Metrics
- phpcpd: Copy/Paste Detector (CPD)
- phpdcd: Dead Code Detector (DCD)
- SensioLabs Security Checker: Security Checker
- Continuous Integration (CI) using the following web services:
- Provides a Packagist package which can be installed using the dependency manager Composer. Click here for the package on Packagist.
- Provides a complete Application Programming Interface (API) documentation generated with the documentation generator Sami. Click here for the API documentation.
- Follows the following "standards" from the PHP Framework Interoperability
Group (FIG). PSR stands for PHP Standards Recommendation:
-
PSR-0: Autoloading Standards
Aims to provide a standard file, class and namespace convention to allow plug-and-play code.
-
PSR-1: Basic Coding Standard
Aims to ensure a high level of technical interoperability between shared PHP code.
-
PSR-2: Coding Style Guide
Provides a Coding Style Guide for projects looking to standardize their code.
-
PSR-4: Autoloader
A more modern take on autoloading reflecting advances in the ecosystem.
-
- Follows the Semantic Versioning (SemVer) specification version 2.0.0.
Requirements
Production
Development
- PHPUnit
- phpcpd
- phpdcd
- PHP_CodeSniffer
- PHP Mess Detector (PHPMD)
- Sami
- SensioLabs Security Checker
- php-coveralls
Installation
Component\Util\Singleton should be installed using the dependency manager Composer.
Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.
The Composer installer can be downloaded with php
.
php -r "readfile('https://getcomposer.org/installer');" | php
This will just check a few PHP settings and then download
composer.phar
to your working directory. This file is the Composer binary. It is a PHAR (PHP archive), which is an archive format for PHP 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": { "florianwolters/component-core-stringutils": "0.4.*" } }
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
phpunit
Contributing
Please see CONTRIBUTING for details.
Credits
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 https://gnu.org/licenses/lgpl.txt.