PHP Class Inspekt\Inspekt

Datei anzeigen Open project: funkatron/inspekt Class Usage Examples

Protected Properties

Property Type Description
$useFilterExtension

Public Methods

Method Description
convertArrayToArrayObject ( &$arr ) : ArrayObject Converts an array into an ArrayObject. We use ArrayObjects when walking arrays in Inspekt
escMySQL ( string $value, resource $conn ) : mixed Escapes the value given with mysql_real_escape_string
escPgSQL ( mixed $value, resource $conn = null ) : mixed Escapes the value given with pg_escape_string
escPgSQLBytea ( mixed $value, resource $conn = null ) : mixed Escapes the value given with pg_escape_bytea
getAlnum ( mixed $value ) : mixed Returns only the alphabetic characters and digits in value.
getAlpha ( mixed $value ) : mixed Returns only the alphabetic characters in value.
getDigits ( mixed $value ) : mixed Returns only the digits in value.
getDir ( mixed $value ) : mixed Returns dirname(value).
getInt ( mixed $value ) : integer Returns (int) value.
getPath ( mixed $value ) : mixed Returns realpath(value).
getROT13 ( mixed $value ) : mixed Returns the value encoded as ROT13 (or decoded, if already was ROT13)
isAlnum ( mixed $value ) : boolean Returns true if every character is alphabetic or a digit, false otherwise.
isAlpha ( mixed $value ) : boolean Returns true if every character is alphabetic, false otherwise.
isArrayObject ( $obj ) : boolean Checks to see if this is an ArrayObject
isArrayOrArrayObject ( $arr ) : boolean Checks to see if this is an array or an ArrayObject
isBetween ( mixed $value, mixed $min, mixed $max, boolean $inc = true ) : boolean Returns true if value is greater than or equal to $min and less than or equal to $max, false otherwise. If $inc is set to false, then the value must be strictly greater than $min and strictly less than $max.
isCcnum ( mixed $value, mixed $type = null ) : boolean Returns true if it is a valid credit card number format. The optional second argument allows developers to indicate the type.
isDate ( mixed $value ) : boolean Returns true if value is a valid date, false otherwise. The date is required to be in ISO 8601 format.
isDigits ( mixed $value ) : boolean Returns true if every character is a digit, false otherwise.
isEmail ( string $value ) : boolean Returns true if value is a valid email format, false otherwise.
isFloat ( string $value ) : boolean Returns true if value is a valid float value, false otherwise.
isGreaterThan ( mixed $value, mixed $min ) : boolean Returns true if value is greater than $min, false otherwise.
isHex ( mixed $value ) : boolean Returns true if value is a valid hexadecimal format, false otherwise.
isHostname ( mixed $value, integer $allow = self::ISPK_HOST_ALLOW_ALL ) : boolean Returns true if value is a valid hostname, false otherwise.
isInt ( string | array $value ) : boolean Returns true if value is a valid integer value, false otherwise.
isIp ( mixed $value ) : boolean Returns true if value is a valid IPV4 format, false otherwise.
isLessThan ( mixed $value, mixed $max ) : boolean Returns true if value is less than $max, false otherwise.
isOneOf ( mixed $value, array | string $allowed ) : boolean Returns true if value is one of $allowed, false otherwise.
isPhone ( mixed $value, string $country = 'US' ) : boolean Returns true if value is a valid phone number format, false otherwise. The optional second argument indicates the country.
isRegex ( mixed $value, mixed $pattern ) : mixed Returns true if value matches $pattern, false otherwise. Uses preg_match() for the matching.
isUri ( string $value, integer $mode = self::ISPK_URI_ALLOW_COMMON ) : boolean Enter description here.
isZip ( mixed $value ) : boolean Returns true if value is a valid US ZIP, false otherwise.
makeCookieCage ( string $config_file = null, boolean $strict = true ) : Cage Returns the $_COOKIE data wrapped in an Cage object
makeEnvCage ( string $config_file = null, boolean $strict = true ) : Cage Returns the $_ENV data wrapped in an Cage object
makeFilesCage ( string $config_file = null, boolean $strict = true ) : Cage Returns the $_FILES data wrapped in an Cage object
makeGetCage ( string $config_file = null, boolean $strict = true ) : Cage Returns the $_GET data wrapped in an Cage object
makePostCage ( string $config_file = null, boolean $strict = true ) : Cage Returns the $_POST data wrapped in an Cage object
makeServerCage ( string $config_file = null, boolean $strict = true ) : Cage Returns the $_SERVER data wrapped in an Cage object
makeSuperCage ( string $config_file = null, boolean $strict = true ) : SuperglobalsCage Returns a SuperglobalsCage object, which wraps ALL input superglobals
noPath ( mixed $value ) : mixed Returns basename(value).
noTags ( mixed $value ) : mixed Returns value with all tags removed.
noTagsOrSpecial ( mixed $value ) : array | mixed | string returns value with tags stripped and the chars '"&<> and all ascii chars under 32 encoded as html entities
useFilterExt ( boolean $state = null ) : boolean Sets and/or retrieves whether we should use the PHP filter extensions where possible If a param is passed, it will set the state in addition to returning it

Protected Methods

Method Description
walkArray ( array | ArrayObjec\ArrayObject $input, string $method, string | null $classname = null ) : array Recursively walks an array and applies a given filter method to every value in the array.

Method Details

convertArrayToArrayObject() public static method

Converts an array into an ArrayObject. We use ArrayObjects when walking arrays in Inspekt
public static convertArrayToArrayObject ( &$arr ) : ArrayObject
return ArrayObject

escMySQL() public static method

Escapes the value given with mysql_real_escape_string
public static escMySQL ( string $value, resource $conn ) : mixed
$value string
$conn resource the mysql connection. If none is given, it will use the last link opened, per behavior of mysql_real_escape_string
return mixed

escPgSQL() public static method

If the data is for a column of the type bytea, use Inspekt::escPgSQLBytea()
public static escPgSQL ( mixed $value, resource $conn = null ) : mixed
$value mixed
$conn resource the postgresql connection. If none is given, it will use the last link opened, per behavior of pg_escape_string
return mixed

escPgSQLBytea() public static method

Escapes the value given with pg_escape_bytea
public static escPgSQLBytea ( mixed $value, resource $conn = null ) : mixed
$value mixed
$conn resource the postgresql connection. If none is given, it will use the last link opened, per behavior of pg_escape_bytea
return mixed

getAlnum() public static method

Returns only the alphabetic characters and digits in value.
public static getAlnum ( mixed $value ) : mixed
$value mixed
return mixed

getAlpha() public static method

Returns only the alphabetic characters in value.
public static getAlpha ( mixed $value ) : mixed
$value mixed
return mixed

getDigits() public static method

Returns only the digits in value.
public static getDigits ( mixed $value ) : mixed
$value mixed
return mixed

getDir() public static method

Returns dirname(value).
public static getDir ( mixed $value ) : mixed
$value mixed
return mixed

getInt() public static method

Returns (int) value.
public static getInt ( mixed $value ) : integer
$value mixed
return integer

getPath() public static method

Returns realpath(value).
public static getPath ( mixed $value ) : mixed
$value mixed
return mixed

getROT13() public static method

Returns the value encoded as ROT13 (or decoded, if already was ROT13)
public static getROT13 ( mixed $value ) : mixed
$value mixed
return mixed

isAlnum() public static method

Returns true if every character is alphabetic or a digit, false otherwise.
public static isAlnum ( mixed $value ) : boolean
$value mixed
return boolean

isAlpha() public static method

Returns true if every character is alphabetic, false otherwise.
public static isAlpha ( mixed $value ) : boolean
$value mixed
return boolean

isArrayObject() public static method

Checks to see if this is an ArrayObject
Deprecation:
public static isArrayObject ( $obj ) : boolean
return boolean

isArrayOrArrayObject() public static method

Checks to see if this is an array or an ArrayObject
public static isArrayOrArrayObject ( $arr ) : boolean
return boolean

isBetween() public static method

Returns true if value is greater than or equal to $min and less than or equal to $max, false otherwise. If $inc is set to false, then the value must be strictly greater than $min and strictly less than $max.
public static isBetween ( mixed $value, mixed $min, mixed $max, boolean $inc = true ) : boolean
$value mixed
$min mixed
$max mixed
$inc boolean
return boolean

isCcnum() public static method

Returns true if it is a valid credit card number format. The optional second argument allows developers to indicate the type.
public static isCcnum ( mixed $value, mixed $type = null ) : boolean
$value mixed
$type mixed
return boolean

isDate() public static method

Returns true if value is a valid date, false otherwise. The date is required to be in ISO 8601 format.
public static isDate ( mixed $value ) : boolean
$value mixed
return boolean

isDigits() public static method

This is just like isInt(), except there is no upper limit.
public static isDigits ( mixed $value ) : boolean
$value mixed
return boolean

isEmail() public static method

Returns true if value is a valid email format, false otherwise.
See also: http://www.regular-expressions.info/email.html
See also: self::ISPK_EMAIL_VALID
public static isEmail ( string $value ) : boolean
$value string
return boolean

isFloat() public static method

Returns true if value is a valid float value, false otherwise.
public static isFloat ( string $value ) : boolean
$value string
return boolean

isGreaterThan() public static method

Returns true if value is greater than $min, false otherwise.
public static isGreaterThan ( mixed $value, mixed $min ) : boolean
$value mixed
$min mixed
return boolean

isHex() public static method

Returns true if value is a valid hexadecimal format, false otherwise.
public static isHex ( mixed $value ) : boolean
$value mixed
return boolean

isHostname() public static method

Depending upon the value of $allow, Internet domain names, IP addresses, and/or local network names are considered valid. The default is HOST_ALLOW_ALL, which considers all of the above to be valid.
public static isHostname ( mixed $value, integer $allow = self::ISPK_HOST_ALLOW_ALL ) : boolean
$value mixed
$allow integer bitfield for self::ISPK_HOST_ALLOW_DNS, self::ISPK_HOST_ALLOW_IP, self::ISPK_HOST_ALLOW_LOCAL
return boolean

isInt() public static method

Returns true if value is a valid integer value, false otherwise.
public static isInt ( string | array $value ) : boolean
$value string | array
return boolean

isIp() public static method

Returns true if value is a valid IPV4 format, false otherwise.
public static isIp ( mixed $value ) : boolean
$value mixed
return boolean

isLessThan() public static method

Returns true if value is less than $max, false otherwise.
public static isLessThan ( mixed $value, mixed $max ) : boolean
$value mixed
$max mixed
return boolean

isOneOf() public static method

Returns true if value is one of $allowed, false otherwise.
public static isOneOf ( mixed $value, array | string $allowed ) : boolean
$value mixed
$allowed array | string
return boolean

isPhone() public static method

This method requires that the value consist of only digits.
public static isPhone ( mixed $value, string $country = 'US' ) : boolean
$value mixed
$country string
return boolean

isRegex() public static method

Returns true if value matches $pattern, false otherwise. Uses preg_match() for the matching.
public static isRegex ( mixed $value, mixed $pattern ) : mixed
$value mixed
$pattern mixed
return mixed

isUri() public static method

..
public static isUri ( string $value, integer $mode = self::ISPK_URI_ALLOW_COMMON ) : boolean
$value string
$mode integer
return boolean

isZip() public static method

Returns true if value is a valid US ZIP, false otherwise.
public static isZip ( mixed $value ) : boolean
$value mixed
return boolean

makeCookieCage() public static method

This utilizes a singleton pattern to get around scoping issues
public static makeCookieCage ( string $config_file = null, boolean $strict = true ) : Cage
$config_file string
$strict boolean whether or not to nullify the superglobal array
return Cage

makeEnvCage() public static method

This utilizes a singleton pattern to get around scoping issues
public static makeEnvCage ( string $config_file = null, boolean $strict = true ) : Cage
$config_file string
$strict boolean whether or not to nullify the superglobal array
return Cage

makeFilesCage() public static method

This utilizes a singleton pattern to get around scoping issues
public static makeFilesCage ( string $config_file = null, boolean $strict = true ) : Cage
$config_file string
$strict boolean whether or not to nullify the superglobal array
return Cage

makeGetCage() public static method

This utilizes a singleton pattern to get around scoping issues
public static makeGetCage ( string $config_file = null, boolean $strict = true ) : Cage
$config_file string
$strict boolean whether or not to nullify the superglobal array
return Cage

makePostCage() public static method

This utilizes a singleton pattern to get around scoping issues
public static makePostCage ( string $config_file = null, boolean $strict = true ) : Cage
$config_file string
$strict boolean whether or not to nullify the superglobal array
return Cage

makeServerCage() public static method

This utilizes a singleton pattern to get around scoping issues
public static makeServerCage ( string $config_file = null, boolean $strict = true ) : Cage
$config_file string
$strict boolean whether or not to nullify the superglobal array
return Cage

makeSuperCage() public static method

Returns a SuperglobalsCage object, which wraps ALL input superglobals
public static makeSuperCage ( string $config_file = null, boolean $strict = true ) : SuperglobalsCage
$config_file string
$strict boolean whether or not to nullify the superglobal
return SuperglobalsCage

noPath() public static method

Returns basename(value).
public static noPath ( mixed $value ) : mixed
$value mixed
return mixed

noTags() public static method

This will utilize the PHP Filter extension if available
public static noTags ( mixed $value ) : mixed
$value mixed
return mixed

noTagsOrSpecial() public static method

This will utilize the PHP Filter extension if available
public static noTagsOrSpecial ( mixed $value ) : array | mixed | string
$value mixed
return array | mixed | string @mixed

useFilterExt() public static method

We use this method of storing in a static class property so that we can access the value outside of class instances
public static useFilterExt ( boolean $state = null ) : boolean
$state boolean optional
return boolean

walkArray() protected static method

This should be considered a "protected" method, and not be called outside of the class
protected static walkArray ( array | ArrayObjec\ArrayObject $input, string $method, string | null $classname = null ) : array
$input array | ArrayObjec\ArrayObject
$method string
$classname string | null
return array

Property Details

$useFilterExtension protected_oe static_oe property

protected static $useFilterExtension