FileAccess Orion

Result
in package

Define common system status exchange object

This is the default and minimal form of a result object used in all file access systems.

Tags
category

Interface object

author

Tobias Teichner webmaster@teichner.biz

since

File available since v0.01

Table of Contents

$data  : array<string|int, mixed>|mixed
The result payload
$errors  : array<string|int, mixed>
The list of errors
$message  : array<string|int, mixed>
The response message buffer
$second_data  : null|mixed
secondary result values
$sort_by  : string|null
The sort by property name
$status  : bool|null
The status code
__construct()  : mixed
Construct a new instance of the result object
_sort()  : int
Sort helper
AddEntry()  : mixed
Append entry
AddEntryAssoc()  : static
Add associative entry
ClearMessage()  : mixed
Clear messages
Count()  : bool|int
The amount of values Gives the length of the result data set or, false
GetAssoc()  : array<string|int, mixed>
get the data get all the data as assoc array
getErrors()  : array<string|int, mixed>|string
get the error messages Translate errors or get plain data.
GetErrorsCount()  : int
state count errors get the numeric count of registered errors
getMessage()  : array<string|int, mixed>|string
Get the messages Translate errors or get plain data.
getSecondaryValue()  : mixed|null
Get secondary value
getSecondaryValues()  : mixed
get the data get the whole secondary data set
getStatus()  : mixed
get the current status getter for the local status
getValue()  : mixed
Get the data by key
getValues()  : mixed
Get the data sorted by
hasError()  : mixed|null
hasErrors()  : bool
Check if this status has errors
setError()  : mixed
Set new error
SetErrorMessage()  : Result
Set error message
setMessage()  : Result
Add or override the current message
SetResponses()  : Result
Merge error result
SetSecondaryValue()  : mixed
Update a single secondary values entry
SetSecondaryValues()  : mixed
add or override the current data
setStatus()  : Result
add or override the current status This method can be chained
SetValidValues()  : void
Override the current data and set status true
setValues()  : mixed
Set the current data
map()  : string
map and translate data create a readable result string from a given set of result templates

Properties

$data

The result payload

private array<string|int, mixed>|mixed $data = array()

$errors

The list of errors

private array<string|int, mixed> $errors = array()

$message

The response message buffer

private array<string|int, mixed> $message = array()

$second_data

secondary result values

private null|mixed $second_data = null

$sort_by

The sort by property name

private string|null $sort_by = null

$status

The status code

private bool|null $status = null

Methods

__construct()

Construct a new instance of the result object

public __construct([bool $status = false ][, string $message = "" ][, array<string|int, mixed> $values = array() ][, array<string|int, mixed> $second_data = array() ]) : mixed
Parameters
$status : bool = false

The boolean state of the initialised status

$message : string = ""

The first message

$values : array<string|int, mixed> = array()

The initial result data set

$second_data : array<string|int, mixed> = array()

The initial secondary result data set

Return values
mixed

_sort()

Sort helper

public _sort( $a,  $b) : int
Parameters
$a :
$b :
Return values
int

AddEntry()

Append entry

public AddEntry(mixed $entry, int $max) : mixed

This method adds the given entry to the result data It converts the data storage to an array on demand

Parameters
$entry : mixed

A new entry to the result set

$max : int

The maximum count of elements

Return values
mixed

AddEntryAssoc()

Add associative entry

public AddEntryAssoc(string $key, mixed $value) : static

This method adds a new entry to the result data object It converts the data storage to an array on demand

Parameters
$key : string

The assoc key

$value : mixed

A new entry to the result set

Return values
static

ClearMessage()

Clear messages

public ClearMessage() : mixed
Return values
mixed

Count()

The amount of values Gives the length of the result data set or, false

public Count() : bool|int
Return values
bool|int

GetAssoc()

get the data get all the data as assoc array

public GetAssoc([int $format = FAA_RESULT_TYPE_PLAIN ][, string $l = '' ][, bool $empty_null = false ]) : array<string|int, mixed>
Parameters
$format : int = FAA_RESULT_TYPE_PLAIN

The result format type

$l : string = ''

The result language

$empty_null : bool = false

When true, empty values will be skipped

Return values
array<string|int, mixed>

The associative representation of this object

getErrors()

get the error messages Translate errors or get plain data.

public getErrors([int $format = FAA_RESULT_TYPE_PLAIN ][, string $l = '' ]) : array<string|int, mixed>|string
Parameters
$format : int = FAA_RESULT_TYPE_PLAIN

The result format type

$l : string = ''

The result language

Return values
array<string|int, mixed>|string

Either the plain set of errors or a translated message

GetErrorsCount()

state count errors get the numeric count of registered errors

public GetErrorsCount() : int
Return values
int

The count of local errors

getMessage()

Get the messages Translate errors or get plain data.

public getMessage([int $format = FAA_RESULT_TYPE_PLAIN ][, string|null $l = null ][, bool $allow_html = false ]) : array<string|int, mixed>|string
Parameters
$format : int = FAA_RESULT_TYPE_PLAIN

The result format type

$l : string|null = null

The result language

$allow_html : bool = false

Allow html in values

Return values
array<string|int, mixed>|string

Either the plain set of errors or a translated message

getSecondaryValue()

Get secondary value

public getSecondaryValue(string $key) : mixed|null
Parameters
$key : string
Return values
mixed|null

getSecondaryValues()

get the data get the whole secondary data set

public getSecondaryValues() : mixed
Return values
mixed

getStatus()

get the current status getter for the local status

public getStatus() : mixed
Return values
mixed

getValue()

Get the data by key

public getValue(int|string $key) : mixed

Get a node of the plain buffered values. Supports array and object values

Parameters
$key : int|string

A certain value part to return

Return values
mixed

The property or value when inside the storage, otherwise null

getValues()

Get the data sorted by

public getValues([string $sort_by = '' ]) : mixed

Get the plain buffered value

Parameters
$sort_by : string = ''

Set to certain existing key to enable sorted response or false

Return values
mixed

The property or value when inside the storage, otherwise null

hasError()

public hasError( $key) : mixed|null
Parameters
$key :
Return values
mixed|null

hasErrors()

Check if this status has errors

public hasErrors() : bool

Returns true if this result object has errors in the buffer.

Return values
bool

Result if this object has errors

setError()

Set new error

public setError(string|array<string|int, mixed> $key[, string $val = '' ][, array<string|int, mixed>|null $var = null ]) : mixed

Can set an array of errors or a assoc error entry

Parameters
$key : string|array<string|int, mixed>

The key of the message

$val : string = ''

The Value of the message

$var : array<string|int, mixed>|null = null

An associative array with variable parameters to parse into the translation

Return values
mixed

SetErrorMessage()

Set error message

public SetErrorMessage(string $msg[, array<string|int, mixed>|null $var = null ]) : Result

Convenience function to set message and status at once Set the message and the status to false. This method is chainable

Parameters
$msg : string

The new message

$var : array<string|int, mixed>|null = null

An associative array with variable parameters to parse into the translation

Return values
Result

setMessage()

Add or override the current message

public setMessage(string|array<string|int, mixed> $msg[, array<string|int, mixed>|null $var = null ]) : Result
Parameters
$msg : string|array<string|int, mixed>

The new message

$var : array<string|int, mixed>|null = null

An associative array with variable parameters to parse into the translation

Return values
Result

SetResponses()

Merge error result

public SetResponses(Result $result[, bool $full = false ]) : Result

Merge with other error result object This method can be chained

Parameters
$result : Result

The other result

$full : bool = false

Also merge data on demand

Return values
Result

SetSecondaryValue()

Update a single secondary values entry

public SetSecondaryValue( $key,  $data) : mixed
Parameters
$key :
$data :
Return values
mixed

SetSecondaryValues()

add or override the current data

public SetSecondaryValues(mixed $data[, mixed $value = null ]) : mixed
Parameters
$data : mixed

The new data set or a key name

$value : mixed = null

The new value when data was a string key

Return values
mixed

setStatus()

add or override the current status This method can be chained

public setStatus(bool $status) : Result
Parameters
$status : bool

The new status

Return values
Result

SetValidValues()

Override the current data and set status true

public SetValidValues(mixed $data[, bool $attach = false ]) : void
Parameters
$data : mixed

The new data for the values

$attach : bool = false

Add instead of override

Return values
void

setValues()

Set the current data

public setValues(mixed $data[, bool $append = false ]) : mixed
Parameters
$data : mixed

The new data for the values

$append : bool = false
Return values
mixed

map()

map and translate data create a readable result string from a given set of result templates

private map(array<string|int, mixed> $assoc[, string|null $l = null ][, bool $allow_html = false ]) : string
Parameters
$assoc : array<string|int, mixed>

A combined text with arguments to map

$l : string|null = null

The target translation language code or false in plain mode

$allow_html : bool = false
Return values
string

The mapped translated template with parsed args

Search results