lithium\console\Command::_response()
Handles the response that is sent to the stream.
Parameters
-
string
$type
The stream either output or error.
-
string|array
$string
The message to render.
-
mixed
$options
When passed an integer or boolean it is used as the number of of new lines, when passed a string it is interpreted as style to use otherwise when an array following options are available:
'nl'
integer|boolean: number of new lines to add at the end.false
to disable adding a newline.'style'
string: the style name to wrap around the output.
Returns
voidSource
protected function _response($type, $string, $options) {
$defaults = ['nl' => 1, 'style' => null];
if (!is_array($options)) {
if (is_bool($options)) {
$options = ['nl' => (integer) $options];
} elseif (is_int($options)) {
$options = ['nl' => $options];
} elseif (is_string($options)) {
$options = ['style' => $options];
} else {
$options = [];
}
}
$options += $defaults;
if (is_array($string)) {
$method = ($type == 'error' ? $type : 'out');
foreach ($string as $out) {
$this->{$method}($out, $options);
}
return;
}
if ($options['style'] !== null) {
$string = "{:{$options['style']}}{$string}{:end}";
}
if ($options['nl']) {
$string = $string . $this->nl((integer) $options['nl']);
}
return $this->response->{$type}($string);
}