php-censor/src/PHPCensor/Helper/AnsiConverter.php
2017-03-12 11:40:40 +07:00

47 lines
889 B
PHP

<?php
namespace PHPCensor\Helper;
use SensioLabs\AnsiConverter\AnsiToHtmlConverter;
/**
* Converts ANSI output to HTML.
*/
final class AnsiConverter
{
static private $converter = null;
/**
* Initialize the singleton.
*
* @return AnsiToHtmlConverter
*/
private static function getInstance()
{
if (self::$converter === null) {
self::$converter = new AnsiToHtmlConverter(null, false);
}
return self::$converter;
}
/**
* Convert a text containing ANSI color sequences into HTML code.
*
* @param string $text The text to convert
*
* @return string The HTML code.
*/
public static function convert($text)
{
return self::getInstance()->convert($text);
}
/**
* Do not instantiate this class.
*/
private function __construct()
{
}
}