boomdraw/canonicalizer
Composer 安装命令:
composer require boomdraw/canonicalizer
包简介
Canonicalizer package for Laravel
README 文档
README
Canonicalizer package for Laravel
Installation
Via Composer
$ composer require boomdraw/canonicalizer
Laravel
The package will automatically register itself.
Lumen
Uncomment the following line in the bootstrap file:
// bootstrap/app.php: $app->withFacades();
Register CanonicalizerServiceProvider
// bootstrap/app.php: $app->register(Boomdraw\Canonicalizer\CanonicalizerServiceProvider::class);
Usage examples
use Boomdraw\Canonicalizer\Facades\Canonicalizer;
or
use Canonicalizer;
Methods
Canonicalizer
Canonicalizer::canonicalize()
Args string $string, bool $nullEmpty = true
Returns canonicalized string or null if $nullEmpty = true and the string is empty.
Canonicalizer::email()
Args: string $email
Returns canonicalized email without dots before @ or null if the string does not contain @
Canonicalizer::slug()
Args: string $title, string $separator = '-', ?string $language = 'en'
\Illuminate\Support\Str::slug() alias
Canonicalizer::url()
Args: string $url, string $separator = '-'
The function calls trim() function with slash (/) and backslash (\) added to charlist and slugs url path items
with specified separator.
Canonicalizer::uri()
Args: sstring $url, string $separator = '-'
Canonicalizer::url() alias
Canonicalizer::macro()
Args string $name, object|callable $macro = true
Canonicalizer uses Macroable trait, so you can add methods to a class dynamically.
Canonicalizer::macro('replaceSpaces', function(string $string) { return str_replace(' ', '', $string); }); Canonicalizer::replaceSpaces('Hello World!') === 'HelloWorld!';
Testing
You can run the tests with:
composer test
Contributing
Please see CONTRIBUTING for details and a todo list.
Security
If you discover any security-related issues, please email pkgsecurity@boomdraw.com instead of using the issue tracker.
License
统计信息
- 总下载量: 1.05k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-12-06