Constants

NORMAL

NORMAL

Color indices

BLACK

BLACK

RED

RED

GREEN

GREEN

YELLOW

YELLOW

BLUE

BLUE

MAGENTA

MAGENTA

CYAN

CYAN

WHITE

WHITE

GRAY

GRAY

BOLD_RED

BOLD_RED

BOLD_GREEN

BOLD_GREEN

BOLD_YELLOW

BOLD_YELLOW

BOLD_BLUE

BOLD_BLUE

BOLD_MAGENTA

BOLD_MAGENTA

BOLD_CYAN

BOLD_CYAN

BOLD_WHITE

BOLD_WHITE

Properties

$width

$width : integer

Console character width

Type

integer

$indent

$indent : string

Console indentation

Type

string

$response

$response : string

Console response body

Type

string

$commands

$commands : array

Commands

Type

array

$header

$header : string

Console header

Type

string

$headerSent

$headerSent : boolean

Flag for if console header has been sent

Type

boolean

$footer

$footer : string

Console footer

Type

string

$helpColors

$helpColors : array

Help colors

Type

array

$colorMap

$colorMap : array

Color map of ansi values

Type

array

Methods

__construct()

__construct(integer  $width = 80, string  $indent = '    ') 

Instantiate a new console object

Parameters

integer $width
string $indent

setWidth()

setWidth(integer  $width) : \Pop\Console\Console

Set the wrap width of the console object

Parameters

integer $width

Returns

\Pop\Console\Console

setIndent()

setIndent(string  $indent = null) : \Pop\Console\Console

Set the indentation of the console object

Parameters

string $indent

Returns

\Pop\Console\Console

setHeader()

setHeader(string  $header) : \Pop\Console\Console

Set the console header

Parameters

string $header

Returns

\Pop\Console\Console

setFooter()

setFooter(string  $footer) : \Pop\Console\Console

Set the console footer

Parameters

string $footer

Returns

\Pop\Console\Console

setHeaderSent()

setHeaderSent(boolean  $headerSent = true) : \Pop\Console\Console

Set the console header sent flag

Parameters

boolean $headerSent

Returns

\Pop\Console\Console

setHelpColors()

setHelpColors(integer  $color1, integer  $color2 = null, integer  $color3 = null) : \Pop\Console\Console

Set the console help colors

Parameters

integer $color1
integer $color2
integer $color3

Returns

\Pop\Console\Console

getWidth()

getWidth() : integer

Get the wrap width of the console object

Returns

integer

getIndent()

getIndent() : string

Get the indentation of the console object

Returns

string

getHeader()

getHeader(boolean  $formatted = false) : string

Get the console header

Parameters

boolean $formatted

Returns

string

getFooter()

getFooter(boolean  $formatted = false) : string

Get the console footer

Parameters

boolean $formatted

Returns

string

getHeaderSent()

getHeaderSent() : boolean

Get the console header sent flag

Returns

boolean

getHelpColors()

getHelpColors() : array

Get the console help colors

Returns

array

addCommands()

addCommands(array  $commands) : \Pop\Console\Console

Add commands

Parameters

array $commands

Returns

\Pop\Console\Console

getCommands()

getCommands() : array

Get commands

Returns

array

getCommand()

getCommand(string  $command) : \Pop\Console\Command

Get a command

Parameters

string $command

Returns

\Pop\Console\Command

hasCommand()

hasCommand(string  $command) : boolean

Check if the console object has a command

Parameters

string $command

Returns

boolean

addCommandsFromRoutes()

addCommandsFromRoutes(\Pop\Router\Match\Cli  $routeMatch, string  $scriptName = null) : \Pop\Console\Console

Add commands from routes

Parameters

\Pop\Router\Match\Cli $routeMatch
string $scriptName

Returns

\Pop\Console\Console

help()

help(string  $command = null) : string

Get a help

Parameters

string $command

Returns

string

colorize()

colorize(string  $string, integer  $fg = null, integer  $bg = null) : string

Colorize a string for output

Parameters

string $string
integer $fg
integer $bg

Returns

string

prompt()

prompt(string  $prompt, array  $options = null, boolean  $caseSensitive = false, integer  $length = 500, boolean  $withHeaders = true) : string

Get input from the prompt

Parameters

string $prompt
array $options
boolean $caseSensitive
integer $length
boolean $withHeaders

Returns

string

append()

append(string  $text = null, boolean  $newline = true) : \Pop\Console\Console

Append a string of text to the response body

Parameters

string $text
boolean $newline

Returns

\Pop\Console\Console

write()

write(string  $text = null, boolean  $newline = true, boolean  $withHeaders = true) : \Pop\Console\Console

Write a string of text to the response body and send the response

Parameters

string $text
boolean $newline
boolean $withHeaders

Returns

\Pop\Console\Console

send()

send(boolean  $withHeaders = true) : \Pop\Console\Console

Send the response

Parameters

boolean $withHeaders

Returns

\Pop\Console\Console

displayHelp()

displayHelp() : void

Display console help

clear()

clear() : void

Clear the console

getColorCode()

getColorCode(integer  $color, string  $type = 'foreground') : mixed

Get the color code from the color map

Parameters

integer $color
string $type

Returns

mixed

formatTemplate()

formatTemplate(string  $template) : string

Format header or footer template

Parameters

string $template

Returns

string