\NeuronCommandLineApplicationBase

Command line applications are designed to only be executed from the context of the command line.

Allows for easy addition and handling of command line parameters.

Summary

Methods
Properties
Constants
getSetting()
setSetting()
getParameter()
getLogger()
log()
isCommandLine()
__construct()
getVersion()
run()
debug()
info()
warning()
error()
fatal()
No public properties found
No constants found
getHandlers()
addHandler()
processParameters()
help()
onStart()
getParameters()
onFinish()
onError()
onRun()
$_aParameters
$_aSettings
N/A
No private methods found
$_aHandlers
$_Logger
N/A

Properties

$_aParameters

$_aParameters

$_aSettings

$_aSettings

$_aHandlers

$_aHandlers

$_Logger

$_Logger

Methods

getSetting()

getSetting( $sName,  $sSection)

Parameters

$sName
$sSection

setSetting()

setSetting( $sName,  $sValue,  $sSection)

Parameters

$sName
$sValue
$sSection

getParameter()

getParameter(mixed $s) : mixed

Parameters

mixed $s

Returns

mixed

log()

log(mixed $s, int $iLevel)

Parameters

mixed $s
int $iLevel

isCommandLine()

isCommandLine() : bool

Returns

bool

__construct()

__construct(\Neuron\Log\ILogger $Logger)

Parameters

\Neuron\Log\ILogger $Logger

getVersion()

getVersion() : string

Returns

string —

Application version number. Must be implemented by derived classes.

run()

run(array|null $aArgv)

Parameters

array|null $aArgv

debug()

debug( $s)

Parameters

$s

info()

info( $s)

Parameters

$s

warning()

warning( $s)

Parameters

$s

error()

error( $s)

Parameters

$s

fatal()

fatal( $s)

Parameters

$s

getHandlers()

getHandlers() : array

Returns

array —
  • accessor for the parameter array.

addHandler()

addHandler(mixed $sSwitch, mixed $sDescription, mixed $method, bool|false $bParam)

Parameters

mixed $sSwitch
mixed $sDescription
mixed $method
bool|false $bParam

Adds a handler for command line parameters. The switch is the parameter that causes the specified method to be called. If the bParam parameter is set to true, the token immediately follwing the switch on the command line will be passed as the parameter to the handler.

processParameters()

processParameters()

Processes the argv array.

help()

help()

Activated by he --help parameter. Shows all configured switches and their hints.

onStart()

onStart() : bool

Returns

bool —

Called before onRun. If false is returned, application terminates without executing onRun.

getParameters()

getParameters() : array

Returns

array —

returns parameters passed to the run method.

onFinish()

onFinish()

Called immediately after onRun.

onError()

onError(\Exception $ex) : bool

Parameters

\Exception $ex

Returns

bool —

Called for any unhandled exceptions.

onRun()

onRun() : mixed

Returns

mixed —

Must be implemented by derived classes.