[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/splitbrain/php-cli/src/ -> Base.php (summary)

Class CLIBase All base functionality is implemented here.

Author: Andreas Gohr
License: MIT
File Size: 333 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 14 functions

  __construct()
  run()
  registerDefaultOptions()
  handleDefaultOptions()
  setupLogging()
  parseOptions()
  checkArguments()
  execute()
  setLogLevel()
  isLogLevelEnabled()
  fatal()
  success()
  logMessage()
  interpolate()

Functions
Functions that are not part of a class:

__construct($autocatch = true)   X-Ref
constructor

Initialize the arguments, set up helper classes and set up the CLI environment

param: bool $autocatch should exceptions be catched and handled automatically?

run()   X-Ref
Execute the CLI program

Executes the setup() routine, adds default options, initiate the options parsing and argument checking
and finally executes main() - Each part is split into their own protected function below, so behaviour
can easily be overwritten


registerDefaultOptions()   X-Ref
Add the default help, color and log options


handleDefaultOptions()   X-Ref
Handle the default options


setupLogging()   X-Ref
Handle the logging options


parseOptions()   X-Ref
Wrapper around the option parsing


checkArguments()   X-Ref
Wrapper around the argument checking


execute()   X-Ref
Wrapper around main


setLogLevel($level)   X-Ref
Set the current log level

param: string $level

isLogLevelEnabled($level)   X-Ref
Check if a message with the given level should be logged

param: string $level
return: bool

fatal($error, array $context = array()   X-Ref
Exits the program on a fatal error

param: \Exception|string $error either an exception or an error message
param: array $context

success($string, array $context = array()   X-Ref
Normal, positive outcome (This is not a PSR-3 level)

param: string $string
param: array $context

logMessage($level, $message, array $context = array()   X-Ref

param: string $level
param: string $message
param: array $context

interpolate($message, array $context = array()   X-Ref
Interpolates context values into the message placeholders.

param: $message
param: array $context
return: string