Completed
Push — master ( e4e762...910c9d )
by Harry
14s
created

Terminal::eraseToEnd()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Graze\BufferedConsole\Terminal;
4
5
use Symfony\Component\Console\Terminal as SymfonyTerminal;
6
7
class Terminal implements TerminalInterface
8
{
9
    /** @var CursorInterface */
10
    protected $cursor;
11
    /** @var int */
12
    private $width = self::DEFAULT_WIDTH;
13
    /** @var int */
14
    private $height = self::DEFAULT_HEIGHT;
15
16
    /**
17
     * Terminal will provide cursor and dimension information to the outputter
18
     *
19
     * @param CursorInterface|null $cursor
20
     * @param SymfonyTerminal      $terminal
21
     */
22
    public function __construct(CursorInterface $cursor = null, SymfonyTerminal $terminal = null)
23
    {
24
        $this->cursor = $cursor ?: new ANSI();
25
        $terminal = $terminal ?: new SymfonyTerminal();
26
        $this->width = $terminal->getWidth();
27
        $this->height = $terminal->getHeight();
28
    }
29
30
    /**
31
     * @return int
32
     */
33
    public function getWidth()
34
    {
35
        return $this->width;
36
    }
37
38
    /**
39
     * @return int
40
     */
41
    public function getHeight()
42
    {
43
        return $this->height;
44
    }
45
46
    /**
47
     * Move the cursor to y,x
48
     *
49
     * @param int $line
50
     * @param int $column
51
     *
52
     * @return string
53
     */
54
    public function move($line, $column)
55
    {
56
        return $this->cursor->move($line, $column);
57
    }
58
59
    /**
60
     * Move up n Lines
61
     *
62
     * @param int $lines
63
     *
64
     * @return string
65
     */
66
    public function moveUp($lines)
67
    {
68
        return $this->cursor->moveUp($lines);
69
    }
70
71
    /**
72
     * Move down n Lines
73
     *
74
     * @param int $lines
75
     *
76
     * @return string
77
     */
78
    public function moveDown($lines)
79
    {
80
        return $this->cursor->moveDown($lines);
81
    }
82
83
    /**
84
     * Move left n Columns
85
     *
86
     * @param int $columns
87
     *
88
     * @return string
89
     */
90
    public function moveLeft($columns)
91
    {
92
        return $this->cursor->moveLeft($columns);
93
    }
94
95
    /**
96
     * Move right n Columns
97
     *
98
     * @param int $columns
99
     *
100
     * @return string
101
     */
102
    public function moveRight($columns)
103
    {
104
        return $this->cursor->moveRight($columns);
105
    }
106
107
    /**
108
     * Erase to the end of the line
109
     *
110
     * @return string
111
     */
112
    public function eraseToEnd()
113
    {
114
        return $this->cursor->eraseToEnd();
115
    }
116
117
    /**
118
     * Erase to the start of the line
119
     *
120
     * @return string
121
     */
122
    public function eraseToStart()
123
    {
124
        return $this->cursor->eraseToStart();
125
    }
126
127
    /**
128
     * Erase Down
129
     *
130
     * @return string
131
     */
132
    public function eraseDown()
133
    {
134
        return $this->cursor->eraseDown();
135
    }
136
137
    /**
138
     * Erase Up
139
     *
140
     * @return string
141
     */
142
    public function eraseUp()
143
    {
144
        return $this->cursor->eraseUp();
145
    }
146
147
    /**
148
     * Erase entire screen
149
     *
150
     * @return string
151
     */
152
    public function eraseScreen()
153
    {
154
        return $this->cursor->eraseScreen();
155
    }
156
}
157