Line   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 6
c 1
b 0
f 0
dl 0
loc 48
ccs 10
cts 10
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A erase() 0 3 1
A eraseFromCursor() 0 3 1
A eraseToCursor() 0 3 1
A insert() 0 3 1
A delete() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Cli\Tools;
4
5
use const AlecRabbit\CSI;
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 1
    public static function eraseFromCursor(): string
15
    {
16 1
        return CSI . '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 1
    public static function eraseToCursor(): string
25
    {
26 1
        return CSI . '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 1
    public static function erase(): string
35
    {
36 1
        return CSI . '2K';
37
    }
38
39
    /**
40
     * @param int $num
41
     * @return string
42
     */
43 1
    public static function insert(int $num = 1): string
44
    {
45 1
        return CSI . "{$num}L";
46
    }
47
48
    /**
49
     * @param int $num
50
     * @return string
51
     */
52 1
    public static function delete(int $num = 1): string
53
    {
54 1
        return CSI . "{$num}M";
55
    }
56
}
57