permafrost-dev / laravel-str-extras
Extra helper methods for the Laravel Str helper class.
Fund package maintenance!
permafrost-dev
Requires
- php: ^8.1
- illuminate/contracts: ^10.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
This package is auto-updated.
Last update: 2024-11-09 23:33:24 UTC
README
Extra helper methods for the Laravel Str helper class.
Additional Methods
insert()
- inserts a string at the specified position in the given string.insertAfterMatch()
- inserts a string after the specified pattern match.insertAfter()
- inserts a string after the specified substring.
Examples
$new = Str::insert('HelloWorld', '--', 5); //returns 'Hello--World' $new = Str::insertAfterMatch('HelloWorld', '/(Hello)/', ' '); // returns 'Hello World' $new = Str::insertAfter('HelloWorld', 'H', '_'); // returns 'H_elloWorld'
As far as making building web applications easier - consider the following use case:
// the identifier in the database is UA-1001, but we want to // allow the user to provide the identifier without a dash for ease of entry: $providedIdentifier = 'UA1001'; $actualIdentifier = Str::insertAfter($providedIdentifier, 'UA', '-'); $userExists = User::where('identifier', $actualIdentifier)->exists();
Installation
You can install the package via composer:
composer require permafrost-dev/laravel-str-extras
Usage
$new = Str::insert('HelloWorld', '--', 5); //returns 'Hello--World'
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.