Passed
Push — master ( 277033...d65d01 )
by Radu
01:14
created

Ansi::sgr()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
namespace WebServCo\Framework\Cli;
3
4
final class Ansi
5
{
6
    /**
7
    * Select Graphic Rendition
8
    *
9
    * @see \WebServCo\Framework\Cli\Sgr
10
    *
11
    * @param string $string
12
    * @param array $parameters ANSI SGR parameters (alterantively use the Sgr class constants)
13
    *
14
    * @return string
15
    */
16
    public static function sgr($string, array $parameters)
17
    {
18
        $result = '';
19
        foreach ($parameters as $parameter) {
20
            $result .= sprintf("\e[%sm", $parameter);
21
        }
22
        $result .= $string . sprintf("\e[%sm", Sgr::RESET);
23
        return $result;
24
    }
25
26
    public static function clear()
27
    {
28
        return "\e[H\e[J";
29
    }
30
}
31