Download the PHP package srcoder/normalize-strings without Composer
On this page you can find all versions of the php package srcoder/normalize-strings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download srcoder/normalize-strings
More information about srcoder/normalize-strings
Files in srcoder/normalize-strings
Package normalize-strings
Short Description Re-usable way of normalizing strings
License MIT
Informations about the package normalize-strings
Srcoder\Normalize strings library
Use to normalize strings. Implements most basic conversions. Find a new one, please create a PR :-)
Dependencies
Requires minimum PHP 7.0+
Installation
Rules
Srcoder\Normalize\Rule\Append(string $append)
Srcoder\Normalize\Rule\Prepend(string $prepend)
Srcoder\Normalize\Rule\Lowercase
Srcoder\Normalize\Rule\Uppercase
Srcoder\Normalize\Rule\Replace($search, $replace)
Srcoder\Normalize\Rule\Trim(string $chars)
Srcoder\Normalize\Rule\Words(string $delimiters)
Srcoder\Normalize\Rule\RegExp(string $pattern, string $replacement)
Srcoder\Normalize\Rule\Callback(\Closure $closure)
Srcoder\Normalize\Rule\Safe(RuleInterface $rule, int $limit = -1)
Caching
Normalized strings are cached internally, second lookup for the same string will be returned from cache.
Basic usage
This is basic usage of the normlizer.
Chaining
You can chain normalizer, if it only adds a simple thingy.
Add-/prepend-Rule
You can add or prepend rules to a normalizer.
Multiple rules at once
Just as in the constructor you can add multiple rules.
addRules([Rule, Rule])
prependRules([Rule, Rule])
Adding your own rules
Just implement the Sroder\Normalize\Rule\RuleInterface
Manager (instance)
If you need your normalizers to be available everywhere.
Trait
To use the normalizer in any of your classes you can use the trait.
Tests
All code is covered by tests, if you want to create a PR please run these tests too.