libAllure
 
Loading...
Searching...
No Matches
libAllure\Sanitizer Class Reference

Public Member Functions

 enableSearchingPrefixKeys ()
 
 escapeStringForClean ($content)
 
 escapeStringForConsole ($content)
 
 escapeStringForDatabase ($content)
 
 escapeStringForHtml ($content)
 
 filterAlphanumeric ($name)
 
 filterEnum ($name, array $accepted, $default=null)
 
 filterId ()
 
 filterIdentifier ($name)
 
 filterInputEnum ($name, array $accepted, $default)
 
 filterInputString ($name, $default=null)
 
 filterInt ($name, $min=null, $max=PHP_INT_MAX)
 
 filterNumeric ($content)
 
 filterSint ($name, $min=PHP_INT_MIN, $max=PHP_INT_MAX)
 
 filterString ($name, $default=null)
 
 filterUint ($name, $min=0, $max=PHP_INT_MAX)
 
 filterVariableEnum ($value, array $accepted, $default=null)
 
 formatBool ($content)
 
 formatNumericAsHex ($num)
 
 formatString ($content, $destination=3)
 
 formatStringForDatabase ($content)
 
 formatStringForHtml ($content)
 
 hasInput ($name)
 
 setInputSource ($inputSource)
 
 triggerFailFilter ($message)
 

Static Public Member Functions

static getInstance ()
 

Public Attributes

 $filterAllowUndefined = true
 
const FORMAT_FOR_ALL = 64
 
const FORMAT_FOR_DB = 1
 
const FORMAT_FOR_HTML = 2
 
const INPUT_COOKIE = 5
 
const INPUT_GET = 1
 
const INPUT_POST = 2
 
const INPUT_REQUEST = 3
 
const INPUT_SERVER = 4
 

Detailed Description

Sanitizes and filters input.

This class has an unusual history, and the first thing you will probably ask is why on earth this class exists when PHP has filter_ functions.

It looks like PHP's filter_ function were added in PHP 5.2 (~2006), yet this class was probably written around2005-2008 - and PHP 5.2 either probably was not available on my server, or I just didn't know about the filter_ functions.

However, the filter_ functions interface is incredibly goofy (array of $options, etc), so this class has now been re-written as a wrapper around the filter_ functions.

Member Function Documentation

◆ getInstance()

static libAllure\Sanitizer::getInstance ( )
static

The constructor is still public as it's quite likely that users will want to create instances of this class with different options. This singleton method is useful for getting an instance with sane defaults.