PHP Class Inspekt\Inspekt

Afficher le fichier Open project: funkatron/inspekt Class Usage Examples

Protected Properties

Свойство Type Description
$useFilterExtension

Méthodes publiques

Méthode 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

Méthodes protégées

Méthode 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 méthode

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

escMySQL() public static méthode

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
Résultat mixed

escPgSQL() public static méthode

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
Résultat mixed

escPgSQLBytea() public static méthode

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
Résultat mixed

getAlnum() public static méthode

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

getAlpha() public static méthode

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

getDigits() public static méthode

Returns only the digits in value.
public static getDigits ( mixed $value ) : mixed
$value mixed
Résultat mixed

getDir() public static méthode

Returns dirname(value).
public static getDir ( mixed $value ) : mixed
$value mixed
Résultat mixed

getInt() public static méthode

Returns (int) value.
public static getInt ( mixed $value ) : integer
$value mixed
Résultat integer

getPath() public static méthode

Returns realpath(value).
public static getPath ( mixed $value ) : mixed
$value mixed
Résultat mixed

getROT13() public static méthode

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

isAlnum() public static méthode

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

isAlpha() public static méthode

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

isArrayObject() public static méthode

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

isArrayOrArrayObject() public static méthode

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

isBetween() public static méthode

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
Résultat boolean

isCcnum() public static méthode

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
Résultat boolean

isDate() public static méthode

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
Résultat boolean

isDigits() public static méthode

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

isEmail() public static méthode

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
Résultat boolean

isFloat() public static méthode

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

isGreaterThan() public static méthode

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

isHex() public static méthode

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

isHostname() public static méthode

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
Résultat boolean

isInt() public static méthode

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

isIp() public static méthode

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

isLessThan() public static méthode

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

isOneOf() public static méthode

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

isPhone() public static méthode

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

isRegex() public static méthode

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
Résultat mixed

isUri() public static méthode

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

isZip() public static méthode

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

makeCookieCage() public static méthode

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
Résultat Cage

makeEnvCage() public static méthode

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
Résultat Cage

makeFilesCage() public static méthode

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
Résultat Cage

makeGetCage() public static méthode

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
Résultat Cage

makePostCage() public static méthode

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
Résultat Cage

makeServerCage() public static méthode

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
Résultat Cage

makeSuperCage() public static méthode

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
Résultat SuperglobalsCage

noPath() public static méthode

Returns basename(value).
public static noPath ( mixed $value ) : mixed
$value mixed
Résultat mixed

noTags() public static méthode

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

noTagsOrSpecial() public static méthode

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

useFilterExt() public static méthode

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
Résultat boolean

walkArray() protected static méthode

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
Résultat array

Property Details

$useFilterExtension protected_oe static_oe property

protected static $useFilterExtension