Passed
Push — master ( 3d6ed7...3d6ed7 )
by Alec
05:30 queued 02:54
created

Terminal::setTitle()   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
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\ConsoleColour;
4
5
use AlecRabbit\ConsoleColour\Core\AbstractColorSupportingTerminal;
6
use AlecRabbit\ConsoleColour\Core\Contracts\TerminalInterface;
7
8
/**
9
 * Class Terminal
10
 * @author AlecRabbit
11
 */
12
class Terminal extends AbstractColorSupportingTerminal implements TerminalInterface
13
{
14
15
    /** {@inheritdoc} */
16 2
    public function width(bool $recheck = false): int
17
    {
18 2
        if (null !== static::$width && true !== $recheck) {
19 2
            return static::$width;
20
        }
21
        return
22 2
            static::$width = $this->getWidth();
23
    }
24
25
26
    /** {@inheritdoc} */
27 2
    public function height(bool $recheck = false): int
28
    {
29 2
        if (null !== static::$height && true !== $recheck) {
30 2
            return static::$height;
31
        }
32
        return
33 2
            static::$height = $this->getHeight();
34
    }
35
36
    /** {@inheritdoc} */
37 8
    public function supports256Color(bool $recheck = false): bool
38
    {
39 8
        if (null !== static::$supports256Color && true !== $recheck) {
40 8
            return static::$supports256Color;
41
        }
42
        return
43 1
            static::$supports256Color = $this->check256ColorSupport();
44
    }
45
46
    /** {@inheritdoc} */
47 8
    public function supportsColor(bool $recheck = false): bool
48
    {
49 8
        if (null !== static::$supportsColor && true !== $recheck) {
50 8
            return static::$supportsColor;
51
        }
52
        return
53 1
            static::$supportsColor = $this->hasColorSupport();
54
    }
55
56
    /** {@inheritdoc} */
57
    public function setTitle(string $title): void
58
    {
59
        echo "\033]0;{$title}\007"; // bash echo -e "\033]0;$@\007"
60
    }
61
}
62
63
64
65