\Phabstractic\Data\Types\ResourceFilterInterface

Filter Interface

A filter is able to test a value against some internal logic. It will return true if it passes, false otherwise. There is also a static function that must be implemented that enables you to check an array of values against the internal test.

CHANGELOG

1.0: Created FilterInterface - April 11th, 2015 2.0: reformatted for inclusion in phabstractic - July 13th, 2016

Summary

Methods
Constants
isAllowed()
checkElements()
getDefaultRestrictions()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

isAllowed()

isAllowed(  $type, boolean  $strict = false) : boolean

Is a value allowed through this filter?

Parameters

$type
boolean $strict

Should we throw errors?

Throws

\Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\Exception\InvalidArgumentException

Returns

boolean —

Allowed or not?

checkElements()

checkElements(array  $values, \Phabstractic\Data\Types\Resource\FilterInterface  $filter, boolean  $strict = false) : boolean

Checks values to see if they fit 'through' the filter

This goes through each value, grabs its type, and compares it against the filter

Parameters

array $values

The values to check against the restrictions

\Phabstractic\Data\Types\Resource\FilterInterface $filter
boolean $strict

Throw errors?

Throws

\Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\Exception\InvalidArgumentException

if the value is untypeable, or illegal (only strict)

Returns

boolean —

Valid types?

getDefaultRestrictions()

getDefaultRestrictions() : \Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\Resource\FilterInterface

Retrieve default filter settings

This should be just about any basic filter setting

Returns

\Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\Resource\FilterInterface