permafrost-dev / laravel-str-extras
Laravel Str 辅助类额外的辅助方法。
1.0.1
2023-05-09 16:21 UTC
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-09-09 23:14:02 UTC
README
Laravel Str 辅助类额外的辅助方法。
附加方法
insert()
- 在给定字符串的指定位置插入字符串。insertAfterMatch()
- 在指定模式匹配后插入字符串。insertAfter()
- 在指定子字符串后插入字符串。
示例
$new = Str::insert('HelloWorld', '--', 5); //returns 'Hello--World' $new = Str::insertAfterMatch('HelloWorld', '/(Hello)/', ' '); // returns 'Hello World' $new = Str::insertAfter('HelloWorld', 'H', '_'); // returns 'H_elloWorld'
为了使构建Web应用更简单,请考虑以下用例
// 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();
安装
您可以通过composer安装此包
composer require permafrost-dev/laravel-str-extras
使用
$new = Str::insert('HelloWorld', '--', 5); //returns 'Hello--World'
测试
composer test
变更日志
请参阅CHANGELOG以获取有关最近更改的更多信息。
贡献
请参阅CONTRIBUTING以获取详细信息。
安全漏洞
请审查我们的安全策略以了解如何报告安全漏洞。
致谢
许可
MIT许可(MIT)。请参阅许可文件以获取更多信息。