File: /var/www/limestate-api/Models/Output.php
<?php
class Output
{
const FONT_YELLOW = "\033[33m\033[1m";
const FONT_WHITE = "\033[47m\033[1m";
const FONT_GREEN = "\033[47m\033[1m";
const FONT_LIGHT_GREY = "\033[37m\033[2m";
const BG_RED = "\033[41m";
const BG_GREEN = "\033[42m";
const NORMAL = "\033[0m";
public static function log($string)
{
echo self::FONT_LIGHT_GREY
. ' - ' . $string . PHP_EOL
. self::NORMAL;
}
public static function title($string)
{
echo self::FONT_YELLOW
. '========================================================================' . PHP_EOL
. ' ' . $string . PHP_EOL
. '========================================================================' . PHP_EOL
. self::NORMAL . PHP_EOL;
}
public static function header($string)
{
echo self::FONT_YELLOW . PHP_EOL
. ' ' . $string . PHP_EOL
. '------------------------------------------------------------------------' . PHP_EOL
. self::NORMAL . PHP_EOL;
}
public static function error($string)
{
echo PHP_EOL
. self::BG_RED . self::FONT_WHITE . PHP_EOL
. PHP_EOL . "\t" . str_replace("\n", "\n\t", $string) . PHP_EOL
. self::NORMAL . PHP_EOL . PHP_EOL;
}
public static function write($string)
{
echo ' ' . $string . PHP_EOL;
}
public static function rewrite($string)
{
$numNewLines = substr_count($string, PHP_EOL);
echo chr(27) . "[0G"; // Set cursor to first column
echo chr(27) . "[" . $numNewLines ."A"; // Set cursor up x lines
echo str_pad($string, 80) . PHP_EOL;
}
public static function success($string)
{
echo PHP_EOL . ' ' . self::FONT_WHITE . self::BG_GREEN
. ' ' . $string . ' '
. self::NORMAL . ' ' . PHP_EOL . PHP_EOL;
}
}