class SafeParams

A thin class that manages a collection of SafeParam objects

This class exists rather than having $params directly in Input because a param can itself contain a collection of other params (see SafeParam::TYPE_OBJECT) represented by another SafeParams

Constants

PARAMLOG_NEVER

Never log this input parameter (always used for RAW)

PARAMLOG_ONLYFULL

Log the parameter only if details is full

PARAMLOG_ALWAYS

Log the parameter if log details are enabled

Properties

private $params
private $logref
private $loglevel

Methods

bool
HasParam(string $key)

Returns true if the named parameter exists

AddParam(string $key, $value)

Adds the parameter to this object with the given name and value

SetLogRef(array|null $logref, int $loglevel)

Takes an array reference for logging fetched parameters

void
LogData(int|null $minlog, int $type, string $key, $data)

Logs the given $data as $key or sets a sub-log reference if it's a SafeParams

GetParam(string $key, int $type, int $minlog = self::PARAMLOG_ONLYFULL, array|null $values = null, callable|null $valfunc = null)

Gets the requested parameter (present and not null)

GetOptParam(string $key, int $type, int $minlog = self::PARAMLOG_ONLYFULL, array|null $values = null, callable|null $valfunc = null)

Same as GetParam() but returns null if the param is not present

GetNullParam(string $key, int $type, int $minlog = self::PARAMLOG_ONLYFULL, array|null $values = null, callable|null $valfunc = null)

Same as GetParam() but returns null if the param is present and null

GetOptNullParam(string $key, int $type, int $minlog = self::PARAMLOG_ONLYFULL, array|null $values = null, callable|null $valfunc = null)

Same as GetParam() but returns null if the param is not present, or is present and null

array
GetClientObject()

Returns a plain associative array of each parameter's name mapped to its raw value

Details

at line 27
bool HasParam(string $key)

Returns true if the named parameter exists

Parameters

string $key

Return Value

bool

at line 33
SafeParams AddParam(string $key, $value)

Adds the parameter to this object with the given name and value

Parameters

string $key
$value

Return Value

SafeParams

at line 43
SafeParams SetLogRef(array|null $logref, int $loglevel)

Takes an array reference for logging fetched parameters

Parameters

array|null $logref
int $loglevel

Return Value

SafeParams

at line 47
protected void LogData(int|null $minlog, int $type, string $key, $data)

Logs the given $data as $key or sets a sub-log reference if it's a SafeParams

Parameters

int|null $minlog
int $type
string $key
$data

Return Value

void

at line 78
GetParam(string $key, int $type, int $minlog = self::PARAMLOG_ONLYFULL, array|null $values = null, callable|null $valfunc = null)

Gets the requested parameter (present and not null)

Parameters

string $key
int $type
int $minlog

minimum log level for logging (0 for never) - RAW is never logged!

array|null $values
callable|null $valfunc

Exceptions

SafeParamKeyMissingException

if the parameter is missing

SafeParamNullValueException

if the parameter is null

See also

SafeParam::GetValue

at line 89
GetOptParam(string $key, int $type, int $minlog = self::PARAMLOG_ONLYFULL, array|null $values = null, callable|null $valfunc = null)

Same as GetParam() but returns null if the param is not present

Parameters

string $key
int $type
int $minlog
array|null $values
callable|null $valfunc

at line 100
GetNullParam(string $key, int $type, int $minlog = self::PARAMLOG_ONLYFULL, array|null $values = null, callable|null $valfunc = null)

Same as GetParam() but returns null if the param is present and null

Parameters

string $key
int $type
int $minlog
array|null $values
callable|null $valfunc

at line 110
GetOptNullParam(string $key, int $type, int $minlog = self::PARAMLOG_ONLYFULL, array|null $values = null, callable|null $valfunc = null)

Same as GetParam() but returns null if the param is not present, or is present and null

Parameters

string $key
int $type
int $minlog
array|null $values
callable|null $valfunc

at line 120
array GetClientObject()

Returns a plain associative array of each parameter's name mapped to its raw value

Return Value

array