tronsha / cerberus

PHP IRC bot
GNU General Public License v3.0
10 stars 2 forks source link

[Insight] Code should not be duplicated - in library/Formatter/FormatterConsole.php, line 89 #3

Closed tronsha closed 9 years ago

tronsha commented 9 years ago

in library/Formatter/FormatterConsole.php, line 89

The next 13 lines appear both in library/Formatter/FormatterConsole.php:89 and library/Formatter/FormatterHtml.php:89.

    public function color($output)
    {
        $coloredOutput = '';
        $xx = $fg = $bg = '';
        $reset = '';
        foreach (str_split($output) as $char) {
            if ($char === "\x03") {
                $xx = 'fg';
            } elseif ($xx === 'fg' && (strlen($fg) === 0 || strlen($fg) === 1) && ord($char) >= 48 && ord($char) <= 57) {
                $fg .= $char;
            } elseif ($xx === 'fg' && (strlen($fg) === 1 || strlen($fg) === 2) && $char === ',') {

Posted from SensioLabsInsight