slick/filter

Filter utilities for Slick Framework

v1.0.5 2016-01-17 01:39 UTC

This package is auto-updated.

Last update: 2024-10-20 11:00:47 UTC


README

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

Slick Filter is a set of filter utilities tah can be used to filter input values, sanitize data and create filter chains to apply on a certain value.

This package is compliant with PSR-2 code standards and PSR-4 autoload standards. It also applies the semantic version 2.0.0 specification.

Install

Via Composer

$ composer require slick/filter

Usage

The best way to filter your data is to use the StaticFilter utility class. It can create any FilterInterface filter and it has alias for the known filters that are bundled with the Slick\Filter package.

use Slick\Filter\StaticFilter;

echo StaticFilter::filter('number', '12 3');  // Will output 123

$text = StaticFilter::filter('text', 123);
echo is_string($text);      // will output 1 (true)

Known filters

Filter chains

It is also possible to combine multiple filters to a single input value by using the FilterChainInterface.

use Slick\Filter\FilterChain;
use Slick\Filter\StaticFilter;

$filterChain = new FilterChain();

$filterChain
    ->add(StaticFilter::create('text'))
    ->add(StaticFilter::create('htmlEntities'));
    
$input = '<p>This is a simple text & cia!</p>';

$output = $filterChain->filter($value);

echo $output;

The above code will output:

This is a simple text &amp; cia!

You can create you own filters by implementing the FilterInterface.

Testing

$ vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email silvam.filipe@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.