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

Ansi::clear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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