code-distortion / laravel-helpers
Various helpers and tools for Laravel
Requires
- php: 8.0.* | 8.1.* | 8.2.*
- illuminate/support: ^7.0 | ^8.0 | ^9.0 | ^10.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- orchestra/testbench: ^5.0 | ^6.0 | ^7.0 | ^8.0
- phpstan/phpstan: ^0.12.98 | ^1.0
- phpunit/phpunit: ^9.0 | ^10.0
- squizlabs/php_codesniffer: ^3.6
README
Warning
This package was developed for use in my own projects. It might not suit your needs or be documented properly, and may change at any time.
Installation
Install the package via composer:
composer require code-distortion/laravel-helpers
The package will automatically register itself.
String Macros
These macros are applied to Illuminate\Support\Str
and Illuminate\Support\Stringable
:
unspace
Trim and remove repeated-spaces from a string:
// ' a b c ' >> 'a b c' Str::unspace($string); Str::of($string)->unspace();
By default, all whitespace characters are searched for and replaced with spaces.
You can specify which character/s to search for:
// '_a__b__c_' >> 'a_b_c' Str::unspace($string, '_'); Str::of($string)->unspace('_');
Searching for an empty string will search for all whitespace characters.
And you can specify a replacement:
// ' a b c ' >> 'a-b-c' Str::unspace($string, ' ', '-'); Str::of($string)->unspace(' ', '-');
If no replacement is specified, the character being searched for will be used.
If more than one character is being searched for, a space is used as the replacement.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Contributions are not being sought for this package.
Security
If you discover any security related issues, please email tim@code-distortion.net instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.