$v )
{
header($v);
}
}
}
/**
* trace
*
* Produces formatted output that terminates the operation.
*
* @param string $message
*
* @return void
*/
public static function trace(string $message, $exit = true, $consoleEnabled = true)
{
# Shows console trace
if( $consoleEnabled && defined('CONSOLE_ENABLED') )
{
self::consoleTrace('CONSOLE TRACE', $message, $exit);
}
$style = 'border:solid 1px #E1E4E5;';
$style .= 'background:#FEFEFE;';
$style .= 'padding:10px;';
$style .= 'margin-bottom:10px;';
$style .= 'font-family:Calibri, Ebrima, Century Gothic, Consolas, Courier New, Courier, monospace, Tahoma, Arial;';
$style .= 'color:#666;';
$style .= 'text-align:left;';
$style .= 'font-size:14px;';
$message = preg_replace('/\[(.*?)\]/', '$1', $message);
$str = "
";
$str .= $message;
$str .= '
';
if( $exit === true && ! defined('ZN_REDIRECT_NOEXIT') )
{
exit($str); // @codeCoverageIgnore
}
return $str;
}
/**
* Console trace
*
* @param string $title
* @param string $message
*/
public static function consoleTrace(string $title, string $message, $exit = true)
{
$repeat = self::presuffix(str_repeat('-', strlen($message) + 2), '+');
$spaceRepeatCount = strlen($message) - strlen($title);
$spaceRepeat = $spaceRepeatCount > 0 ? $spaceRepeatCount : 0;
$titleSpaceRepeat = str_repeat(' ', $spaceRepeat);
$output = $repeat . CRLF;
$output .= '| '.$title . $titleSpaceRepeat .' |' . CRLF;
$output .= $repeat . CRLF;
$output .= '| ' . $message . ' |' . CRLF;
$output .= $repeat;
if( $exit === true && ! defined('ZN_REDIRECT_NOEXIT') )
{
exit($output); // @codeCoverageIgnore
}
return $output;
}
}