Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace Termwind;
6
 
7
use Symfony\Component\Console\Terminal as ConsoleTerminal;
8
 
9
/**
10
 * @internal
11
 */
12
final class Terminal
13
{
14
    /**
15
     * An instance of Symfony's console terminal.
16
     */
17
    private ConsoleTerminal $terminal;
18
 
19
    /**
20
     * Creates a new terminal instance.
21
     */
22
    public function __construct(ConsoleTerminal $terminal = null)
23
    {
24
        $this->terminal = $terminal ?? new ConsoleTerminal();
25
    }
26
 
27
    /**
28
     * Gets the terminal width.
29
     */
30
    public function width(): int
31
    {
32
        return $this->terminal->getWidth();
33
    }
34
 
35
    /**
36
     * Gets the terminal height.
37
     */
38
    public function height(): int
39
    {
40
        return $this->terminal->getHeight();
41
    }
42
 
43
    /**
44
     * Clears the terminal screen.
45
     */
46
    public function clear(): void
47
    {
48
        Termwind::getRenderer()->write("\ec");
49
    }
50
}