abstract class IOInterface extends Singleton

Describes an abstract PHP I/O interface abstraction

Constants

OUTPUT_PLAIN

OUTPUT_JSON

OUTPUT_PRINTR

Properties

static private $instances from  Singleton
protected Input[] $inputs
protected $outmode
private $retfuncs
private $numretfuncs

Methods

static Singleton
GetInstance()

Get the instance of the singleton

__construct()

Construct the singleton for use.

static IOInterface|null
TryGet()

Constructs and returns a singleton of the appropriate interface type

static bool
isApplicable()

Returns whether or not the interface is in use for this request

static bool
isPrivileged()

Returns whether or not the interface grants privileged access

void
Initialize()

Called during API construction to initialize the interface, e.g. to gather global arguments

array
GetInputs(Config|null $config)

Retrieves an array of input objects to run

array
subGetInputs(Config|null $config)

No description

void
DisallowBatch()

Asserts that only one output was given

string
getAddress()

Returns the address of the user on the interface

string
getUserAgent()

Returns the user agent string on the interface

int
GetDebugLevel()

Returns the debugging level requested by the interface

int
GetMetricsLevel()

Returns the perf metrics level requested by the interface

string|null
GetDBConfigFile()

Returns the path to the DB config file requested by the interface

static int
GetDefaultOutmode()

Gets the default output mode for the interface

SetOutputMode(int|null $mode)

Sets the output mode to the given mode or null (none) - NOT USED in "multi-output" mode!

RegisterOutputHandler(OutputHandler $f)

Registers a user output handler function to run after the initial commit

bool
isMultiOutput()

Returns true if the output is using multi-output mode

static string
formatSize(int $size)

Returns the binary-packed version of the given integer size

bool
UserOutput(Output $output)

Tells the interface to run the custom user output functions

WriteOutput(Output $output)

Tells the interface to print its final output

Details

in Singleton at line 21
static Singleton GetInstance()

Get the instance of the singleton

Return Value

Singleton

Exceptions

MissingSingletonException

if not yet constructed

at line 97
__construct()

Construct the singleton for use.

This can be overriden if it requires more arguments

Exceptions

DuplicateSingletonException

if already constructed

at line 36
static IOInterface|null TryGet()

Constructs and returns a singleton of the appropriate interface type

Return Value

IOInterface|null

at line 44
abstract static bool isApplicable()

Returns whether or not the interface is in use for this request

Return Value

bool

at line 47
abstract static bool isPrivileged()

Returns whether or not the interface grants privileged access

Return Value

bool

at line 50
void Initialize()

Called during API construction to initialize the interface, e.g. to gather global arguments

Return Value

void

at line 59
array GetInputs(Config|null $config)

Retrieves an array of input objects to run

Parameters

Config|null $config

Return Value

array

at line 66
abstract protected array subGetInputs(Config|null $config)

No description

Parameters

Config|null $config

Return Value

array

See also

\Andromeda\Core\IOFormat\self::GetInputs()

at line 69
void DisallowBatch()

Asserts that only one output was given

Return Value

void

at line 76
abstract string getAddress()

Returns the address of the user on the interface

Return Value

string

at line 79
abstract string getUserAgent()

Returns the user agent string on the interface

Return Value

string

at line 82
int GetDebugLevel()

Returns the debugging level requested by the interface

Return Value

int

at line 85
int GetMetricsLevel()

Returns the perf metrics level requested by the interface

Return Value

int

at line 88
string|null GetDBConfigFile()

Returns the path to the DB config file requested by the interface

Return Value

string|null

at line 93
abstract static int GetDefaultOutmode()

Gets the default output mode for the interface

Return Value

int

at line 100
IOInterface SetOutputMode(int|null $mode)

Sets the output mode to the given mode or null (none) - NOT USED in "multi-output" mode!

Parameters

int|null $mode

Return Value

IOInterface

at line 112
IOInterface RegisterOutputHandler(OutputHandler $f)

Registers a user output handler function to run after the initial commit

Sets the output mode to null if bytes !== null and will cause "multi-output" mode to be used if > 1 functions that return > 0 bytes are defined

Parameters

OutputHandler $f

Return Value

IOInterface

See also

IOInterface::isMultiOutput

at line 135
protected bool isMultiOutput()

Returns true if the output is using multi-output mode

Multi-output mode is used when more than one user output function wants to run. To accomodate this, each section will be prefaced with the number of bytes written. In multi-output mode, the requested global output mode is ignored and the request is always finished with JSON output (also with the # of bytes prefixed)

Return Value

bool

See also

IOInterface::formatSize

at line 142
static protected string formatSize(int $size)

Returns the binary-packed version of the given integer size

unsigned long long (always 64 bit, big-endian byte order)

Parameters

int $size

Return Value

string

at line 148
bool UserOutput(Output $output)

Tells the interface to run the custom user output functions

Parameters

Output $output

Return Value

bool

true if a custom function was run

at line 163
abstract WriteOutput(Output $output)

Tells the interface to print its final output

Parameters

Output $output