Stringy
Stringy - Object Oriented Manipulation of Strings in PHP!
Install / Use
/learn @mpclarkson/StringyREADME
Stringy - Object Oriented Manipulation of Strings in PHP!
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
Method | Parameters | Returns --- | --- | --- string | nil | string truncate | $chars = 50, $appendWith = "..." | $this length | nil | int contains | $substring | bool startsWith | $substring | bool endsWith | $substring | bool append | $string | $this reverse | nil | $this uppercase | nil | $this uppercaseFirst | nil | $this lowercase | nil | $this lowercaseFirst | nil | $this titleCase | nil | $this sentenceCase | nil | $this toArray | $delimiter = null | array apply | callback | $this
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.
Related Skills
node-connect
337.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
337.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.3kCommit, push, and open a PR

