Request implements IRequestFilter
Filter for Request variables, such as superglobals $_GET, $_POST etc
Tags
Table of Contents
Interfaces
Constants
- ACTION_CLEAR = 'clear'
- ACTION_FILTER = 'filter'
- ACTION_NONE = 'none'
Methods
- __construct() : mixed
- filter() : array<string|int, mixed>
- Return array with filtered values
- getChangedVars() : array<string|int, mixed>
- Return all changed variables, can be useful for logging
- isAuditorsTriggered() : bool
- setAuditors() : $this
- Set auditors for use in filtration
Constants
ACTION_CLEAR
public
mixed
ACTION_CLEAR
= 'clear'
ACTION_FILTER
public
mixed
ACTION_FILTER
= 'filter'
ACTION_NONE
public
mixed
ACTION_NONE
= 'none'
Methods
__construct()
public
__construct([mixed $customOptions = array() ]) : mixed
Parameters
- $customOptions : mixed = array()
filter()
Return array with filtered values
public
filter(array<string|int, mixed> $values[, bool $isReturnChangedOnly = true ]) : array<string|int, mixed>
Simple example:
$ob = new Request();
$ob->setAuditors([
'SQL' => new Auditor\Sql()
]);
print_r(
$ob->filter([
'get' => ['safe bar'],
'post' => ['select * from foo']
])
);
//output: Array ( [post] => Array ( [0] => sel ect * fr om foo ) )
print_r( $ob->filter([ 'get' => ['safe bar'], 'post' => ['select * from foo'] ], false ) ); //output: Array ( [get] => Array ( [0] => safe bar ) [post] => Array ( [0] => sel ect * fr om foo ) )
Parameters
- $values : array<string|int, mixed>
-
array("get" => $_GET, "post" => $_POST, "files" => $_FILES, "cookie" => $_COOKIE)
- $isReturnChangedOnly : bool = true
-
if true - return values only if it changed by some auditors
Tags
Return values
array<string|int, mixed>getChangedVars()
Return all changed variables, can be useful for logging
public
getChangedVars() : array<string|int, mixed>
Return values
array<string|int, mixed>isAuditorsTriggered()
public
isAuditorsTriggered() : bool
Tags
Return values
boolsetAuditors()
Set auditors for use in filtration
public
setAuditors(array<string|int, Base> $auditors) : $this
Parameters
- $auditors : array<string|int, Base>