2017 © Pedro Peláez
 

library str-helper

A flexible & powerful string manipulation helper for PHP

image

awssat/str-helper

A flexible & powerful string manipulation helper for PHP

  • Saturday, March 24, 2018
  • by abdumu
  • Repository
  • 1 Watchers
  • 25 Stars
  • 32 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

str-helper

Latest Version on Packagist StyleCI Build Status, (*1)

⚡️ 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 ...)., (*2)

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., (*3)

Install/Use

You can install the package via composer locally in your project folder:, (*4)

$ composer require awssat/str-helper

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

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":, (*6)

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

There is a "tap" method:, (*7)

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

for callbacks use "do" method:, (*8)

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

or:, (*9)

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., (*10)

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

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

if can take an anonymous function, (*12)

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

All methods are availabe to be called statically, as:, (*13)

StrHelper::capitalize('life');

or using str() function., (*14)

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

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

Tests

Simply use:, (*16)

$ composer test

Credits

License

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

The Versions

24/03 2018

dev-master

9999999-dev https://github.com/awssat/str-helper

A flexible & powerful string manipulation helper for PHP

  Sources   Download

MIT

The Requires

  • php ~7.0

 

The Development Requires

by Awssat

laravel helper manipulation string str

24/03 2018

dev-analysis-z9VvB9

dev-analysis-z9VvB9 https://github.com/awssat/str-helper

A flexible & powerful string manipulation helper for PHP

  Sources   Download

MIT

The Requires

  • php ~7.0

 

The Development Requires

by Awssat

laravel helper manipulation string str

13/03 2018

2.1

2.1.0.0 https://github.com/awssat/str-helper

A flexible & powerful string manipulation helper for PHP

  Sources   Download

MIT

The Requires

  • php ~7.0

 

The Development Requires

by Awssat

laravel helper manipulation string str

12/03 2018

2.0

2.0.0.0 https://github.com/awssat/str-helper

A flexible & powerful string manipulation helper for PHP

  Sources   Download

MIT

The Requires

  • php ~7.0

 

The Development Requires

by Awssat

laravel helper manipulation string str

17/12 2017

1.5

1.5.0.0 https://github.com/awssat/str-helper

A flexible & powerful string manipulation helper for PHP

  Sources   Download

MIT

The Requires

  • php ~7.0

 

The Development Requires

by Awssat

laravel helper manipulation string str

23/11 2017

1.4

1.4.0.0 https://github.com/awssat/str-helper

A flexible & powerful string manipulation helper for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Awssat

laravel helper manipulation string str

22/11 2017

1.3

1.3.0.0 https://github.com/awssat/str-helper

A flexible & powerful string manipulation helper for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Awssat

laravel helper manipulation string str

21/11 2017

1.2

1.2.0.0 https://github.com/awssat/str-helper

Simple and powerful Laravel Support/Str helper.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Awssat

laravel chain string str

20/11 2017

1.1

1.1.0.0 https://github.com/awssat/str-helper

Simple and powerful Laravel Support/Str helper.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Awssat

laravel chain string str

19/11 2017

1.0

1.0.0.0 https://github.com/awssat/str-helper

Simple and powerful Laravel Support/Str helper.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Awssat

laravel chain string str