Download the PHP package jgswift/kfiltr without Composer
On this page you can find all versions of the php package jgswift/kfiltr. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package kfiltr
kfiltr
PHP 5.5+ filtering pattern implementation
Installation
Install via cli using composer:
Install via composer.json using composer:
Description
Kfiltr provides a set of generic traits that handle filtering, mapping, and hooking in a domain-agnostic way.
Interfaces are also provided to broadly describe the intended implementation, however they are required to use this package.
Dependency
- php 5.5+
Usage
Filters
A minimal Filter example. The execute method does not enforce any particular signature and may define whatever arguments needed
Delegate
Effectively a filter is the same except that filters can be bypassed by a custom callable.
Mappers
Similar to the Filter approach above, the Mapping approach is used specifically for populating already instantiated objects with input data Using a mapper requires jgswift/qtil
If no method is provided then a default mapping callback will be used. The default mapping callback assumes that input is an array and object is an object respectively.
Hooks
To assist filter processing, a standard hook implementation is provided. Hooks are containers for multiple filters that typically run sequentially. Hooks may also be filters, but are not by default. In the example below, the hook will iterate over and perform all contained filtering operations.
Factory Filter/Mapper
Filter
Using this filter requires jgswift/qtil
Factory filters make objects using a class map. Arguments are passed to the constructor
Mapper
This filter makes object using a factory and maps the properties using kfiltr\Mapper. Arguments are mapped and the constructor must be empty for mapped classes. To map objects with non-empty constructors, a custom factory is required. Using this filter requires jgswift/qtil