Download the PHP package el-gitto-junior/string without Composer
On this page you can find all versions of the php package el-gitto-junior/string. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package string
The String Gear
A collection of basic string manipulation functions. There are 2 APIs:
- One procedural based using name spaced functions / static method calls.
- And a more fluent object based API.
I am not going to bother documenting every single last function here but please see below for some general usage examples. The rest you can work out for yourself by reading the source, it's fairly straight forward and well commented.
How to Install
Installation via composer is easy:
composer require gears/string:*
How to Use
Here are a few procedural examples:
In PHP 5.6 you can import functions so you could change the above to:
NOTE: All function names are camelCased.
Prior to PHP 5.6 this is not possible. So you can do this instead:
The factory method: You may wish to use the factory method to initiate a new Gears\String object. When you do, please note how the subsequent method call signature changes. You no longer need to provide the string to be performed on as the first argument. This is automatically done for you. Here is an example:
If an array is returned for example when using the match method, the array will be an array of Gears\String instances not simple PHP strings.
NOTE: Using the procedural API will only ever return standard PHP strings unlike the above.
Laravel Integration
Gears\String has been designed as functionally compatible to the Laravel Str class. Thus if you want you can completely swap out for .
To do so in the file replace the following line:
with:
Credits
Thanks to alecgorge for the inspiration, I have taken his methods re-factored them slightly and added a few of my own methods, into the mix. https://github.com/alecgorge/PHP-String-Class/
Additionally all methods in the class provided by Laravel. Have been integrated into . https://github.com/laravel/framework/blob/4.2/src/Illuminate/Support/Str.php
Developed by Brad Jones - [email protected]