Download the PHP package mpclarkson/stringy without Composer
On this page you can find all versions of the php package mpclarkson/stringy. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mpclarkson/stringy
More information about mpclarkson/stringy
Files in mpclarkson/stringy
Package stringy
Short Description A PHP Library that provides a consistent api for object oriented manipulation of strings.
License Apache-2.0
Homepage https://github.com/mpclarkson/icon-scraper
Informations about the package stringy
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:
You can now do this (and many other things), sensibly!
Yay! :)
Usage
After applying any methods, the underlying text/string can be accessed as follows:
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
:
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.