protected _response ( string $type, string | array $string, mixed $options ) : void | ||
$type | string | The stream either output or error. |
$string | string | array | The message to render. |
$options | mixed | 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. |
return | void |
protected function _response($type, $string, $options)
{
$defaults = array('nl' => 1, 'style' => null);
if (!is_array($options)) {
if (is_bool($options)) {
$options = array('nl' => (int) $options);
} elseif (is_int($options)) {
$options = array('nl' => $options);
} elseif (is_string($options)) {
$options = array('style' => $options);
} else {
$options = array();
}
}
$options += $defaults;
if (is_array($string)) {
$method = $type == 'error' ? $type : 'out';
foreach ($string as $out) {
$this->{$method}($out, $options);
}
return;
}
if ($options['style'] !== null && !$this->plain) {
$string = "{:{$options['style']}}{$string}{:end}";
}
if ($options['nl']) {
$string = $string . $this->nl((int) $options['nl']);
}
return $this->response->{$type}($string);
}