Passed
Push — master ( ada559...ce303d )
by Alec
03:02
created

Line::eraseToEnd()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Cli\Tools;
4
5
use const AlecRabbit\ESC;
6
7
class Line
8
{
9
    /**
10
     * Erase from the current cursor position (inclusive) to the end of the line
11
     *
12
     * @return string
13
     */
14
    public static function eraseFromCursor(): string
15
    {
16
        return ESC . '[0K';
17
    }
18
19
    /**
20
     * Erase from the beginning of the line up to the current cursor position (inclusive)
21
     *
22
     * @return string
23
     */
24
    public static function eraseToCursor(): string
25
    {
26
        return ESC . '[1K';
27
    }
28
29
    /**
30
     * Erase from the beginning of the line up to the current cursor position (inclusive)
31
     *
32
     * @return string
33
     */
34
    public static function erase(): string
35
    {
36
        return ESC . '[2K';
37
    }
38
39
    /**
40
     * @param int $num
41
     * @return string
42
     */
43
    public static function insert(int $num = 1): string
44
    {
45
        return  ESC . "[{$num}L";
46
    }
47
48
    /**
49
     * @param int $num
50
     * @return string
51
     */
52
    public static function delete(int $num = 1): string
53
    {
54
        return  ESC . "[{$num}M";
55
    }
56
}
57