PHP Класс Inspekt\Cage

Наследование: implements IteratorAggregate, implements ArrayAccess, implements Countable
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$autofilter_conf array the holding property for autofilter config
$purifier HTMLPurifer
$user_accessors array where we store user-defined methods

Защищенные свойства (Protected)

Свойство Тип Описание
$source ArrayObject Don't try to access this. ever. Now that we're safely on PHP5, we'll enforce this with the "protected" keyword.

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
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

Приватные методы

Метод Описание
setSource ( array &$newsource ) {@internal we use this to set the data array in factory()}}

Описание методов

__call() публичный Метод

public __call ( $name, $args ) : boolean | mixed
$name
$args
Результат boolean | mixed

__construct() публичный Метод

public __construct ( ) : Cage
Результат Cage

addAccessor() публичный Метод

The dev needs to define a procedural function like so: function foo_bar($cage_object, $arg2, $arg3, $arg4, $arg5...) { ... }
Автор: Ed Finkler
public addAccessor ( string $accessor_name ) : void
$accessor_name string
Результат void

applyAutoFilters() защищенный Метод

См. также: Cage::parseAndApplyAutoFilters
protected applyAutoFilters ( )

buildHTMLPurifierConfig() защищенный Метод

protected buildHTMLPurifierConfig ( $opts ) : HTMLPurifier_Config
$opts
Результат HTMLPurifier_Config

count() публичный Метод

Returns the number of elements in $this->source.
public count ( ) : integer
Результат integer

escMySQL() публичный Метод

public escMySQL ( string $key, resource $conn ) : boolean | mixed
$key string
$conn resource a connection resource
Результат boolean | mixed

escPgSQL() публичный Метод

public escPgSQL ( $key, null $conn = null ) : boolean | mixed
$key
$conn null
Результат boolean | mixed

escPgSQLBytea() публичный Метод

public escPgSQLBytea ( $key, null $conn = null ) : boolean | mixed
$key
$conn null
Результат boolean | mixed

factory() публичный статический Метод

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
Результат Cage

getAlnum() публичный Метод

Returns only the alphabetic characters and digits in value.
public getAlnum ( mixed $key ) : mixed
$key mixed
Результат mixed

getAlpha() публичный Метод

Returns only the alphabetic characters in value.
public getAlpha ( mixed $key ) : mixed
$key mixed
Результат mixed

getDigits() публичный Метод

Returns only the digits in value. This differs from getInt().
public getDigits ( mixed $key ) : mixed
$key mixed
Результат mixed

getDir() публичный Метод

Returns dirname(value).
public getDir ( mixed $key ) : mixed
$key mixed
Результат mixed

getHTMLPurifier() публичный Метод

public getHTMLPurifier ( ) : HTMLPurifier
Результат HTMLPurifier

getInt() публичный Метод

Returns (int) value.
public getInt ( mixed $key ) : integer
$key mixed
Результат integer

getIterator() публичный Метод

Returns an iterator for looping through an ArrayObject.
public getIterator ( ) : ArrayIterator
Результат ArrayIterator

getPath() публичный Метод

Returns realpath(value).
public getPath ( mixed $key ) : mixed
$key mixed
Результат mixed

getPurifiedHTML() публичный Метод

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
Результат mixed purified HTML version of input

getROT13() публичный Метод

Returns ROT13-encoded version
public getROT13 ( string $key ) : mixed
$key string
Результат mixed

getRaw() публичный Метод

Returns value.
public getRaw ( string $key ) : mixed
$key string
Результат mixed

getValue() публичный Метод

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
Результат mixed

getValueOrNull() защищенный Метод

protected getValueOrNull ( $key ) : mixed
$key
Результат mixed

getValueRecursive() защищенный Метод

protected getValueRecursive ( $keys, $data_array, integer $level ) : boolean
$keys
$data_array
$level integer
Результат boolean

keyExists() публичный Метод

Checks if a key exists
public keyExists ( mixed $key ) : boolean
$key mixed
Результат boolean

keyExistsRecursive() защищенный Метод

protected keyExistsRecursive ( $keys, $data_array ) : boolean
$keys
$data_array
Результат boolean

loadHTMLPurifier() публичный Метод

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

noPath() публичный Метод

Returns basename(value).
public noPath ( mixed $key ) : mixed
$key mixed
Результат mixed

noTags() публичный Метод

Returns value with all tags removed.
public noTags ( mixed $key ) : mixed
$key mixed
Результат mixed

noTagsOrSpecial() публичный Метод

public noTagsOrSpecial ( $key ) : array | boolean | mixed | string
$key
Результат array | boolean | mixed | string

offsetExists() публичный Метод

Returns whether the $offset exists in $this->source.
public offsetExists ( mixed $offset ) : boolean
$offset mixed
Результат boolean

offsetGet() публичный Метод

Returns the value at $offset from $this->source.
public offsetGet ( mixed $offset ) : mixed
$offset mixed
Результат mixed

offsetSet() публичный Метод

Sets the value at the specified $offset to value$ in $this->source.
public offsetSet ( mixed $offset, mixed $value ) : void
$offset mixed
$value mixed
Результат void

offsetUnset() публичный Метод

Unsets the value in $this->source at $offset.
public offsetUnset ( mixed $offset ) : void
$offset mixed
Результат void

parseAndApplyAutoFilters() защищенный Метод

См. также: Cage::factory
protected parseAndApplyAutoFilters ( $conf_file, $conf_section )
$conf_file
$conf_section

setHTMLPurifier() публичный Метод

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

setValue() защищенный Метод

Sets a value in the source array. Used by applyAutoFilters.
См. также: Cage::applyAutoFilters
protected setValue ( mixed $key, mixed $val ) : mixed
$key mixed
$val mixed
Результат mixed

setValueRecursive() защищенный Метод

См. также: Cage::setValue
protected setValueRecursive ( $keys, $val, $data_array, integer $level ) : boolean
$keys
$val
$data_array
$level integer
Результат boolean

testAlnum() публичный Метод

Returns value if every character is alphabetic or a digit, FALSE otherwise.
public testAlnum ( mixed $key ) : mixed
$key mixed
Результат mixed

testAlpha() публичный Метод

Returns value if every character is alphabetic, FALSE otherwise.
public testAlpha ( mixed $key ) : mixed
$key mixed
Результат mixed

testBetween() публичный Метод

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
Результат mixed

testCcnum() публичный Метод

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
Результат mixed

testDate() публичный Метод

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
Результат mixed

testDigits() публичный Метод

This is just like isInt(), except there is no upper limit.
public testDigits ( mixed $key ) : mixed
$key mixed
Результат mixed

testEmail() публичный Метод

Returns value if it is a valid email format, FALSE otherwise.
public testEmail ( mixed $key ) : mixed
$key mixed
Результат mixed

testFloat() публичный Метод

Returns value if it is a valid float value, FALSE otherwise.
public testFloat ( mixed $key ) : mixed
$key mixed
Результат mixed

testGreaterThan() публичный Метод

Returns value if it is greater than $min, FALSE otherwise.
public testGreaterThan ( mixed $key, mixed $min = null ) : mixed
$key mixed
$min mixed
Результат mixed

testHex() публичный Метод

Returns value if it is a valid hexadecimal format, FALSE otherwise.
public testHex ( mixed $key ) : mixed
$key mixed
Результат mixed

testHostname() публичный Метод

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
Результат mixed

testInt() публичный Метод

Returns value if it is a valid integer value, FALSE otherwise.
public testInt ( mixed $key ) : mixed
$key mixed
Результат mixed

testIp() публичный Метод

Returns value if it is a valid IP format, FALSE otherwise.
public testIp ( mixed $key ) : mixed
$key mixed
Результат mixed

testLessThan() публичный Метод

Returns value if it is less than $max, FALSE otherwise.
public testLessThan ( mixed $key, mixed $max = null ) : mixed
$key mixed
$max mixed
Результат mixed

testOneOf() публичный Метод

Returns value if it is one of $allowed, FALSE otherwise.
public testOneOf ( mixed $key, null $allowed = null ) : mixed
$key mixed
$allowed null
Результат mixed

testPhone() публичный Метод

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
Результат mixed

testRegex() публичный Метод

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
Результат mixed

testUri() публичный Метод

..
public testUri ( string $key ) : boolean | string
$key string
Результат boolean | string

testZip() публичный Метод

Returns value if it is a valid US ZIP, FALSE otherwise.
public testZip ( mixed $key ) : mixed
$key mixed
Результат mixed

Описание свойств

$autofilter_conf публичное свойство

the holding property for autofilter config
public array $autofilter_conf
Результат array

$purifier публичное свойство

public HTMLPurifer $purifier
Результат HTMLPurifer

$source защищенное свойство

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
Результат ArrayObject

$user_accessors публичное свойство

where we store user-defined methods
public array $user_accessors
Результат array