mpclarkson / stringy
A PHP Library that provides a consistent api for object oriented manipulation of strings.
Installs: 2 139
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is auto-updated.
Last update: 2024-12-08 14:48:26 UTC
README
Overview
Are you stick to death of PHP's inconsistencies in terms on manipulating strings? Well, look no further!
Rather than constantly having to write obtuse code like this to check if a string contains a substring:
strpos($mystring, $substring) !== false ? true : false;
You can now do this (and many other things), sensibly!
$string = new String($myString); $bool = $string->contains($substring);
Yay! :)
Usage
After applying any methods, the underlying text/string can be accessed as follows:
$stringy = new Stringy("mystring"); $stringy->append("is fun", " "); echo $stringy->string(); //"mystring is fun";
Methods
Checkout the tests for examples of each method.
Requirements
- PHP 5.4+
Composer
Use Composer by adding the following lines in your composer.json
:
"require": { "mpclarkson/stringy": "dev-master" },
Todos
- More methods
- Contributions welcome
Credits
This has been inspired by the beautify string manipulation in Apple's Swift language.
Thanks goes to Paper Planes Digital Marketing in Brisbane.