All Projects → awssat → Str Helper

awssat / Str Helper

Licence: mit
⚡️ A flexible & powerful string manipulation helper for PHP | using pipe method chaining

Projects that are alternatives of or similar to Str Helper

Go Pretty
Pretty print tables and more in golang!
Stars: ✭ 777 (+1842.5%)
Mutual labels:  string-manipulation
Magrittr
Improve the readability of R code with the pipe
Stars: ✭ 838 (+1995%)
Mutual labels:  pipe
Mightystring
Making Ruby Strings Powerful
Stars: ✭ 28 (-30%)
Mutual labels:  string-manipulation
Ipt
Interactive Pipe To: The Node.js cli interactive workflow
Stars: ✭ 783 (+1857.5%)
Mutual labels:  pipe
Dynamicstring
PHP Template based random string generator
Stars: ✭ 23 (-42.5%)
Mutual labels:  string-manipulation
Id Card
身份证号校验及信息获取
Stars: ✭ 14 (-65%)
Mutual labels:  packagist
Utils
A collection of useful PHP functions, mini classes and snippets that you need and can use every day.
Stars: ✭ 750 (+1775%)
Mutual labels:  string-manipulation
Shell Functools
Functional programming tools for the shell
Stars: ✭ 971 (+2327.5%)
Mutual labels:  string-manipulation
Stringplus
Funny and minimal string library for C++ inspired by underscore.string
Stars: ✭ 7 (-82.5%)
Mutual labels:  string-manipulation
Pandas
Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
Stars: ✭ 32,029 (+79972.5%)
Mutual labels:  flexible
Bludit
Simple, Fast, Secure, Flat-File CMS
Stars: ✭ 824 (+1960%)
Mutual labels:  flexible
Chr
🔤 Lightweight R package for manipulating [string] characters
Stars: ✭ 18 (-55%)
Mutual labels:  string-manipulation
Param pipe
parameterized pipe in elixir: |n>
Stars: ✭ 14 (-65%)
Mutual labels:  pipe
Bash My Aws
Bash-my-AWS provides simple but powerful CLI commands for managing AWS resources
Stars: ✭ 782 (+1855%)
Mutual labels:  pipe
Angularconcepts
Key Angular Concepts using Latest Angular version 5
Stars: ✭ 31 (-22.5%)
Mutual labels:  pipe
Ngx Mask
Angular Plugin to make masks on form fields and html elements.
Stars: ✭ 772 (+1830%)
Mutual labels:  pipe
Fsharp Data Processing Pipeline
Provides an extensible solution for creating Data Processing Pipelines in F#.
Stars: ✭ 13 (-67.5%)
Mutual labels:  pipe
Cracking The Coding Interview
Solutions for Cracking the Coding Interview - 6th Edition
Stars: ✭ 35 (-12.5%)
Mutual labels:  string-manipulation
Packagist Mirror
Creates Packagist.org mirror site.
Stars: ✭ 32 (-20%)
Mutual labels:  packagist
Transport Pipes
Buildcraft without mods!
Stars: ✭ 21 (-47.5%)
Mutual labels:  pipe

str-helper

Latest Version on Packagist StyleCI Build Status

⚡️ A flexible, simple & yet powerful string manipulation helper for PHP. It gives you the magic of method chaining and it's easier and shorter to be included in views. It Supports most of PHP built-in strings functions (and other useful methods like: contains, equal, append, prepend ...).

str('Hi World')->replace(' ', '+')->lower();

Why use this instead of other string maniplulation packages ?

This is a wrapper for PHP default string functions, to provide a very poweful method chaining and conditions. You don't have to learn new methods names, just use PHP functions names that you know.

Install/Use

You can install the package via composer locally in your project folder:

$ composer require awssat/str-helper

After installing it, just start using StrHelper class, or simply the helper function str():

Examples

str('Hi Hello')->strReplace(' ', '-');
>> hi-hello
str('Hi Hello')->prepend('[')->append(']');
>> [Hi Hello]

In case you want an explicit string value for conditions, use "get":

if(str('Hi')->lower->get() == 'hi') {
        echo 'yes'; 
}
>> yes

There is a "tap" method:

str('LINK.COM')->tap(function($v){ print($v); })->lower();
>> LINK.COM

for callbacks use "do" method:

str('<a>link.com</a>')->do(function($string){ 
        return strip_tags($string); 
});
>> link.com

or:

str('<a>link.com</a>')->do(function(){   
        $this->stripTags();
});
>> link.com

you may notice using camelCase instead of snake_case for method name works too.

You can also use conditions, if(..), else(), endif()

str('<html>hi</html>')
            ->ifContains('hi')
            ->upper();
>> <HTML>HI</HTML>       

if can take an anonymous function

str('<html>hi</html>')
            ->if(function(){
                    return $this->contains('hi');
            })
            ->upper();
>> <HTML>HI</HTML>       

All methods are availabe to be called statically, as:

StrHelper::capitalize('life');

or using str() function.

str()::capitalize('nomad');

[UTF-8 Support] If mbstring library is installed and you call a strpos function, mb_strpos will be called instead.

Tests

Simply use:

$ composer test

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].