PHP Class Inspekt\Cage

Inheritance: implements IteratorAggregate, implements ArrayAccess, implements Countable
Afficher le fichier Open project: funkatron/inspekt Class Usage Examples

Méthodes publiques

Свойство Type Description
$autofilter_conf array the holding property for autofilter config
$purifier HTMLPurifer
$user_accessors array where we store user-defined methods

Protected Properties

Свойство Type Description
$source ArrayObject Don't try to access this. ever. Now that we're safely on PHP5, we'll enforce this with the "protected" keyword.

Méthodes publiques

Méthode Description
__call ( $name, $args ) : boolean | mixed
__construct ( ) : Cage
addAccessor ( string $accessor_name ) : void This method lets the developer add new accessor methods to a cage object Note that calling these will be quite a bit slower, because we have to use call_user_func()
count ( ) : integer Returns the number of elements in $this->source.
escMySQL ( string $key, resource $conn ) : boolean | mixed
escPgSQL ( $key, null $conn = null ) : boolean | mixed
escPgSQLBytea ( $key, null $conn = null ) : boolean | mixed
factory ( array &$source, string $conf_file = null, string $conf_section = null, boolean $strict = true ) : Cage Takes an array and wraps it inside an object. If $strict is not set to FALSE, the original array will be destroyed, and the data can only be accessed via the object's accessor methods
getAlnum ( mixed $key ) : mixed Returns only the alphabetic characters and digits in value.
getAlpha ( mixed $key ) : mixed Returns only the alphabetic characters in value.
getDigits ( mixed $key ) : mixed Returns only the digits in value. This differs from getInt().
getDir ( mixed $key ) : mixed Returns dirname(value).
getHTMLPurifier ( ) : HTMLPurifier
getInt ( mixed $key ) : integer Returns (int) value.
getIterator ( ) : ArrayIterator Returns an iterator for looping through an ArrayObject.
getPath ( mixed $key ) : mixed Returns realpath(value).
getPurifiedHTML ( string $key ) : mixed This returns the value of the given key passed through the HTMLPurifer object, if it is instantiated with Cage::loadHTMLPurifer
getROT13 ( string $key ) : mixed Returns ROT13-encoded version
getRaw ( string $key ) : mixed Returns value.
getValue ( string $key ) : mixed Retrieves a value from the source array. This should NOT be called directly, but needs to be public for use by AccessorAbstract. Maybe a different approach should be considered
keyExists ( mixed $key ) : boolean Checks if a key exists
loadHTMLPurifier ( mixed $opts = null ) Load the HTMLPurifier library and instantiate the object
noPath ( mixed $key ) : mixed Returns basename(value).
noTags ( mixed $key ) : mixed Returns value with all tags removed.
noTagsOrSpecial ( $key ) : array | boolean | mixed | string
offsetExists ( mixed $offset ) : boolean Returns whether the $offset exists in $this->source.
offsetGet ( mixed $offset ) : mixed Returns the value at $offset from $this->source.
offsetSet ( mixed $offset, mixed $value ) : void Sets the value at the specified $offset to value$ in $this->source.
offsetUnset ( mixed $offset ) : void Unsets the value in $this->source at $offset.
setHTMLPurifier ( HTMLPurifier $pobj )
testAlnum ( mixed $key ) : mixed Returns value if every character is alphabetic or a digit, FALSE otherwise.
testAlpha ( mixed $key ) : mixed Returns value if every character is alphabetic, FALSE otherwise.
testBetween ( mixed $key, mixed $min, mixed $max, boolean $inc = true ) : mixed Returns value if it 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.
testCcnum ( mixed $key, mixed $type = null ) : mixed Returns value if it is a valid credit card number format. The optional second argument allows developers to indicate the type.
testDate ( mixed $key ) : mixed Returns $value if it is a valid date, FALSE otherwise. The date is required to be in ISO 8601 format.
testDigits ( mixed $key ) : mixed Returns value if every character is a digit, FALSE otherwise.
testEmail ( mixed $key ) : mixed Returns value if it is a valid email format, FALSE otherwise.
testFloat ( mixed $key ) : mixed Returns value if it is a valid float value, FALSE otherwise.
testGreaterThan ( mixed $key, mixed $min = null ) : mixed Returns value if it is greater than $min, FALSE otherwise.
testHex ( mixed $key ) : mixed Returns value if it is a valid hexadecimal format, FALSE otherwise.
testHostname ( mixed $key, integer $allow = Inspekt::ISPK_HOST_ALLOW_ALL ) : mixed Returns value if it is a valid hostname, FALSE otherwise.
testInt ( mixed $key ) : mixed Returns value if it is a valid integer value, FALSE otherwise.
testIp ( mixed $key ) : mixed Returns value if it is a valid IP format, FALSE otherwise.
testLessThan ( mixed $key, mixed $max = null ) : mixed Returns value if it is less than $max, FALSE otherwise.
testOneOf ( mixed $key, null $allowed = null ) : mixed Returns value if it is one of $allowed, FALSE otherwise.
testPhone ( mixed $key, string $country = 'US' ) : mixed Returns value if it is a valid phone number format, FALSE otherwise. The optional second argument indicates the country.
testRegex ( mixed $key, mixed $pattern ) : mixed Returns value if it matches $pattern, FALSE otherwise. Uses preg_match() for the matching.
testUri ( string $key ) : boolean | string Enter description here.
testZip ( mixed $key ) : mixed Returns value if it is a valid US ZIP, FALSE otherwise.

Méthodes protégées

Méthode Description
applyAutoFilters ( )
buildHTMLPurifierConfig ( $opts ) : HTMLPurifier_Config
getValueOrNull ( $key ) : mixed
getValueRecursive ( $keys, $data_array, integer $level ) : boolean
keyExistsRecursive ( $keys, $data_array ) : boolean
parseAndApplyAutoFilters ( $conf_file, $conf_section )
setValue ( mixed $key, mixed $val ) : mixed Sets a value in the source array. Used by applyAutoFilters.
setValueRecursive ( $keys, $val, $data_array, integer $level ) : boolean

Private Methods

Méthode Description
setSource ( array &$newsource ) {@internal we use this to set the data array in factory()}}

Method Details

__call() public méthode

public __call ( $name, $args ) : boolean | mixed
$name
$args
Résultat boolean | mixed

__construct() public méthode

public __construct ( ) : Cage
Résultat Cage

addAccessor() public méthode

The dev needs to define a procedural function like so: function foo_bar($cage_object, $arg2, $arg3, $arg4, $arg5...) { ... }
Author: Ed Finkler
public addAccessor ( string $accessor_name ) : void
$accessor_name string
Résultat void

applyAutoFilters() protected méthode

See also: Cage::parseAndApplyAutoFilters
protected applyAutoFilters ( )

buildHTMLPurifierConfig() protected méthode

protected buildHTMLPurifierConfig ( $opts ) : HTMLPurifier_Config
$opts
Résultat HTMLPurifier_Config

count() public méthode

Returns the number of elements in $this->source.
public count ( ) : integer
Résultat integer

escMySQL() public méthode

public escMySQL ( string $key, resource $conn ) : boolean | mixed
$key string
$conn resource a connection resource
Résultat boolean | mixed

escPgSQL() public méthode

public escPgSQL ( $key, null $conn = null ) : boolean | mixed
$key
$conn null
Résultat boolean | mixed

escPgSQLBytea() public méthode

public escPgSQLBytea ( $key, null $conn = null ) : boolean | mixed
$key
$conn null
Résultat boolean | mixed

factory() public static méthode

Takes an array and wraps it inside an object. If $strict is not set to FALSE, the original array will be destroyed, and the data can only be accessed via the object's accessor methods
public static factory ( array &$source, string $conf_file = null, string $conf_section = null, boolean $strict = true ) : Cage
$source array
$conf_file string
$conf_section string
$strict boolean
Résultat Cage

getAlnum() public méthode

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

getAlpha() public méthode

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

getDigits() public méthode

Returns only the digits in value. This differs from getInt().
public getDigits ( mixed $key ) : mixed
$key mixed
Résultat mixed

getDir() public méthode

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

getHTMLPurifier() public méthode

public getHTMLPurifier ( ) : HTMLPurifier
Résultat HTMLPurifier

getInt() public méthode

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

getIterator() public méthode

Returns an iterator for looping through an ArrayObject.
public getIterator ( ) : ArrayIterator
Résultat ArrayIterator

getPath() public méthode

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

getPurifiedHTML() public méthode

This returns the value of the given key passed through the HTMLPurifer object, if it is instantiated with Cage::loadHTMLPurifer
public getPurifiedHTML ( string $key ) : mixed
$key string
Résultat mixed purified HTML version of input

getROT13() public méthode

Returns ROT13-encoded version
public getROT13 ( string $key ) : mixed
$key string
Résultat mixed

getRaw() public méthode

Returns value.
public getRaw ( string $key ) : mixed
$key string
Résultat mixed

getValue() public méthode

Retrieves a value from the source array. This should NOT be called directly, but needs to be public for use by AccessorAbstract. Maybe a different approach should be considered
public getValue ( string $key ) : mixed
$key string
Résultat mixed

getValueOrNull() protected méthode

protected getValueOrNull ( $key ) : mixed
$key
Résultat mixed

getValueRecursive() protected méthode

protected getValueRecursive ( $keys, $data_array, integer $level ) : boolean
$keys
$data_array
$level integer
Résultat boolean

keyExists() public méthode

Checks if a key exists
public keyExists ( mixed $key ) : boolean
$key mixed
Résultat boolean

keyExistsRecursive() protected méthode

protected keyExistsRecursive ( $keys, $data_array ) : boolean
$keys
$data_array
Résultat boolean

loadHTMLPurifier() public méthode

Load the HTMLPurifier library and instantiate the object
public loadHTMLPurifier ( mixed $opts = null )
$opts mixed options that are sent to HTMLPurifier. Optional

noPath() public méthode

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

noTags() public méthode

Returns value with all tags removed.
public noTags ( mixed $key ) : mixed
$key mixed
Résultat mixed

noTagsOrSpecial() public méthode

public noTagsOrSpecial ( $key ) : array | boolean | mixed | string
$key
Résultat array | boolean | mixed | string

offsetExists() public méthode

Returns whether the $offset exists in $this->source.
public offsetExists ( mixed $offset ) : boolean
$offset mixed
Résultat boolean

offsetGet() public méthode

Returns the value at $offset from $this->source.
public offsetGet ( mixed $offset ) : mixed
$offset mixed
Résultat mixed

offsetSet() public méthode

Sets the value at the specified $offset to value$ in $this->source.
public offsetSet ( mixed $offset, mixed $value ) : void
$offset mixed
$value mixed
Résultat void

offsetUnset() public méthode

Unsets the value in $this->source at $offset.
public offsetUnset ( mixed $offset ) : void
$offset mixed
Résultat void

parseAndApplyAutoFilters() protected méthode

See also: Cage::factory
protected parseAndApplyAutoFilters ( $conf_file, $conf_section )
$conf_file
$conf_section

setHTMLPurifier() public méthode

public setHTMLPurifier ( HTMLPurifier $pobj )
$pobj HTMLPurifier an HTMLPurifer Object

setValue() protected méthode

Sets a value in the source array. Used by applyAutoFilters.
See also: Cage::applyAutoFilters
protected setValue ( mixed $key, mixed $val ) : mixed
$key mixed
$val mixed
Résultat mixed

setValueRecursive() protected méthode

See also: Cage::setValue
protected setValueRecursive ( $keys, $val, $data_array, integer $level ) : boolean
$keys
$val
$data_array
$level integer
Résultat boolean

testAlnum() public méthode

Returns value if every character is alphabetic or a digit, FALSE otherwise.
public testAlnum ( mixed $key ) : mixed
$key mixed
Résultat mixed

testAlpha() public méthode

Returns value if every character is alphabetic, FALSE otherwise.
public testAlpha ( mixed $key ) : mixed
$key mixed
Résultat mixed

testBetween() public méthode

Returns value if it 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 testBetween ( mixed $key, mixed $min, mixed $max, boolean $inc = true ) : mixed
$key mixed
$min mixed
$max mixed
$inc boolean
Résultat mixed

testCcnum() public méthode

Returns value if it is a valid credit card number format. The optional second argument allows developers to indicate the type.
public testCcnum ( mixed $key, mixed $type = null ) : mixed
$key mixed
$type mixed
Résultat mixed

testDate() public méthode

Returns $value if it is a valid date, FALSE otherwise. The date is required to be in ISO 8601 format.
public testDate ( mixed $key ) : mixed
$key mixed
Résultat mixed

testDigits() public méthode

This is just like isInt(), except there is no upper limit.
public testDigits ( mixed $key ) : mixed
$key mixed
Résultat mixed

testEmail() public méthode

Returns value if it is a valid email format, FALSE otherwise.
public testEmail ( mixed $key ) : mixed
$key mixed
Résultat mixed

testFloat() public méthode

Returns value if it is a valid float value, FALSE otherwise.
public testFloat ( mixed $key ) : mixed
$key mixed
Résultat mixed

testGreaterThan() public méthode

Returns value if it is greater than $min, FALSE otherwise.
public testGreaterThan ( mixed $key, mixed $min = null ) : mixed
$key mixed
$min mixed
Résultat mixed

testHex() public méthode

Returns value if it is a valid hexadecimal format, FALSE otherwise.
public testHex ( mixed $key ) : mixed
$key mixed
Résultat mixed

testHostname() public 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 testHostname ( mixed $key, integer $allow = Inspekt::ISPK_HOST_ALLOW_ALL ) : mixed
$key mixed
$allow integer bitfield for HOST_ALLOW_DNS, HOST_ALLOW_IP, HOST_ALLOW_LOCAL
Résultat mixed

testInt() public méthode

Returns value if it is a valid integer value, FALSE otherwise.
public testInt ( mixed $key ) : mixed
$key mixed
Résultat mixed

testIp() public méthode

Returns value if it is a valid IP format, FALSE otherwise.
public testIp ( mixed $key ) : mixed
$key mixed
Résultat mixed

testLessThan() public méthode

Returns value if it is less than $max, FALSE otherwise.
public testLessThan ( mixed $key, mixed $max = null ) : mixed
$key mixed
$max mixed
Résultat mixed

testOneOf() public méthode

Returns value if it is one of $allowed, FALSE otherwise.
public testOneOf ( mixed $key, null $allowed = null ) : mixed
$key mixed
$allowed null
Résultat mixed

testPhone() public méthode

Returns value if it is a valid phone number format, FALSE otherwise. The optional second argument indicates the country.
public testPhone ( mixed $key, string $country = 'US' ) : mixed
$key mixed
$country string
Résultat mixed

testRegex() public méthode

Returns value if it matches $pattern, FALSE otherwise. Uses preg_match() for the matching.
public testRegex ( mixed $key, mixed $pattern ) : mixed
$key mixed
$pattern mixed
Résultat mixed

testUri() public méthode

..
public testUri ( string $key ) : boolean | string
$key string
Résultat boolean | string

testZip() public méthode

Returns value if it is a valid US ZIP, FALSE otherwise.
public testZip ( mixed $key ) : mixed
$key mixed
Résultat mixed

Property Details

$autofilter_conf public_oe property

the holding property for autofilter config
public array $autofilter_conf
Résultat array

$purifier public_oe property

public HTMLPurifer $purifier
Résultat HTMLPurifer

$source protected_oe property

Don't try to access this. ever. Now that we're safely on PHP5, we'll enforce this with the "protected" keyword.
protected ArrayObject $source
Résultat ArrayObject

$user_accessors public_oe property

where we store user-defined methods
public array $user_accessors
Résultat array