Request class

version $Id: request.class.php 2289 2008-09-29 13:46:08Z atelierq $
author Andreas Kummer, w3concepts AG
copyright Copyright © 2008, w3concepts AG

 Methods

Replaces all error objects with null.

finish() : Object

Must be called after registering the required parameters.

Returns

ObjectReference to the current instance.

Returns the GET value of the specified parameter.

get(String $sName, $bWithErrors) : Mixed
Static

Null if it does not exist or if it is not valid.

static
access public

Parameters

$sName

String

sName Name of the parameter.

$bWithErrors

Returns

MixedValue of the parameter or null.

Factory.

getInstance() : Object
Static
static
access public

Returns

ObjectReference to the current single instance of the class.

Returns true, if one of the specified parameters has given a validation error.

hasValidationErrors(String $sRequestType, Array $aParams) : Boolean
Static

Parameters

$sRequestType

String

sRequestType Request type.

$aParams

Array

aParams Array of parameters to be checked.

Returns

BooleanTrue if no validation errors occured. False otherwise.

Returns the POST value of the specified parameter.

post(String $sName, $bWithErrors) : Mixed
Static

Null if it does not exist or if it is not valid.

static
access public

Parameters

$sName

String

sName Name of the parameter.

$bWithErrors

Returns

MixedValue of the parameter or null.

Registers a request variable with the request class.

register(String $sRequestType, String $sName, Integer $iType, Float $iMin, Float $iMax, String $sRegex, $iTransformation) : Object
access public

Parameters

$sRequestType

String

sRequestType Either POST, GET or COOKIE.

$sName

String

sName Parameter name.

$iType

Integer

iType Parameter type (either integer, float or string).

$iMin

Float

iMin Minimum length (string) or minimum value (float, integer).

$iMax

Float

iMax Maximum length (string) or maximum value (float, integer).

$sRegex

String

sRegex Regex pattern the value is checked against.

$iTransformation

Returns

ObjectReference to the current instance to enable method chaining.

Returns the REQUEST value of the specified parameter.

request(String $sName, $bWithErrors) : Mixed
Static

Null if it does not exist or if it is not valid.

static
access private

Parameters

$sName

String

sName Name of the parameter.

$bWithErrors

Returns

MixedValue of the parameter or null.

Constructor.

__construct() 
access private

Returns the parameter specified by sName and the request type sRequestType.

getVar(String $sRequestType, String $sName, $bWithErrors) : Mixed

The method throws an exception if the specified paramter has not yet been registered.

access private

Parameters

$sRequestType

String

sRequestType Request type (GET, POST or COOKIE).

$sName

String

sName Name of the parameter.

$bWithErrors

Returns

MixedValue of the specified parameter.

Callback function to check whether a validation error occured or not.

hasError(\Reference $mItem, Mixed $mKey) : Void
Static
static
access private

Parameters

$mItem

\Reference

mItem Reference to the current item.

$mKey

Mixed

mKey Current key.

Returns

Void

Checks whether or not the given value is a double value.

isFloat(Mixed $mValue) : Boolean
Static
static
access private

Parameters

$mValue

Mixed

mValue Value to be checked.

Returns

BooleanTrue if the value is a float or integer value.

Checks whether or not the given value is a integer value.

isInteger(Mixed $mValue) : Boolean
Static
static
access private

Parameters

$mValue

Mixed

mValue Value to be checked.

Returns

BooleanTrue if the value is a integer value.

isRegistered()

isRegistered($sName, $sRequestType) 

Parameters

$sName

$sRequestType

Callback function to clear the resulting arrays from ValidationError objects.

setErrorsToNull(\Reference $mItem, Mixed $mKey) : Void
Static
static
access private

Parameters

$mItem

\Reference

mItem Reference to the item of the array to be cleared.

$mKey

Mixed

mKey Key of the current item to be processed.

Returns

Void

Sets the member bValidationError to the given value.

setValidationError(Boolean $bValidationError) : Void

Parameters

$bValidationError

Boolean

bValidationError True, if a validation error occured.

Returns

Void

Transforms the value according to the given rules.

transform(String $sValue, Integer $iRules) : String
Static
static
access private

Parameters

$sValue

String

sValue Value to be transformed.

$iRules

Integer

iRules Sum of the transformation rules to be applied.

Returns

StringTransformed value.

Callback function for validating items of arrays.

validateArray(\Reference $mItem, Mixed $mKey, Array $aParams) : Void
Static
static
access private

Parameters

$mItem

\Reference

mItem Reference to the item of the array to be validated.

$mKey

Mixed

mKey Key of the current item to be processed.

$aParams

Array

aParams Parameter array to be used in the validation process.

Returns

Void

Validates the value against type, range, pattern, optionally after a transformation process.

validateValue(Mixed $mValue, Integer $iType, Integer $iMin, Integer $iMax, Integer $sRegex, $iTransformation) : Mixed
Static
static
access private

Parameters

$mValue

Mixed

mValue Value to be validated.

$iType

Integer

iType Type (integer, float or string).

$iMin

Integer

iMin Minimum value (integer and float) or minimum length (string).

$iMax

Integer

iMax Maximum value (integer and float) or maximum length (string).

$sRegex

Integer

iTransformation Sum of transformations to be applied.

$iTransformation

Returns

MixedEither the transformed and validated value or null.

 Properties

   

$COOKIEcleared 
 

$GET 
 

$GETcleared 
 

$POST 
 

$POSTcleared 
 

$bHasValidationErrors 

 Constants

   

DATETIME_PATTERN

DATETIME_PATTERN 
 

DATETIME_PATTERN_DE

DATETIME_PATTERN_DE 
 

DATE_PATTERN_DE

DATE_PATTERN_DE 
 

DATE_PATTERN_ISO

DATE_PATTERN_ISO 
 

GET

GET 
 

HEXDEC_HASH

HEXDEC_HASH 
 

POST

POST 
 

TRANS_STRIP_HTML

TRANS_STRIP_HTML 
 

TRANS_STRIP_PHP

TRANS_STRIP_PHP 
 

TYPE_ARRAY

TYPE_ARRAY 
 

TYPE_FLOAT

TYPE_FLOAT 
 

TYPE_INTEGER

TYPE_INTEGER 
 

TYPE_STRING

TYPE_STRING