sledgehammer/filters

Sledgehammer Filter module. Usefull add-ons using Sledgehammer\filter()

12.11.0 2012-10-24 13:09 UTC

This package is auto-updated.

Last update: 2024-11-17 21:32:05 UTC


README

Adds additional filters compatible with the \Sledgehammer\filter() function.

A filter is a callable that takes only 1 argument (as input) and returns the filterd output.

The buildin functions "addslashes" and "urlencode" for example are compatible with sledgehammer's filter "interface".

Examples

$encoded = filter($myData, 'urlencode'); // Using a global function.

$db = new PDO('sqlite::memory:');
$quoted = filter($myData, array($db, 'quote')); // Using a function in a object/class.

$slug = filter($myData, new SlugFilter()); /// Using a object with an __invoke() method.

$filter = function ($data) { return substr($data, 0, 10); };
$truncated = filter($myData, $filter); // Using a closure.