boomdraw/canonicalizer

Canonicalizer package for Laravel
1,053 1
Install
composer require boomdraw/canonicalizer
Latest Version:v2.0.0
PHP:^7.2
License:MIT
Last Updated:Dec 11, 2019
Links: GitHub  ·  Packagist
Maintainer: boomdraw

Canonicalizer

Canonicalizer package for Laravel

Build Status StyleCI Code Coverage Quality Score Latest Version on Packagist Total Downloads PHP Version License

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

MIT

Related Packages

boomdraw/laravel-dummy-image

Laravel dummy image generator based on kingkool68/dummyimage

1,557 1
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

637,827,751 9,703
laravel/framework

The Laravel Framework.

589,172,971 34,950
laravel/tinker

Powerful REPL for the Laravel framework.

498,216,183 7,442
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

413,412,504 609

Version History

Version Released PHP Laravel License
v2.0.0 ^7.2 5.5.*|5.6.*|5.7.*|5.8.*|^6.0 MIT
v1.1.0 ^7.2 5.5.*|5.6.*|5.7.*|5.8.*|^6.0 MIT
v1.0.0 ^7.2 ~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0 MIT