Passed
Push — master ( 816c76...5c7057 )
by Alec
11:11
created

Terminal::width()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\ConsoleColour;
4
5
use AlecRabbit\ConsoleColour\Contracts\TerminalInterface;
6
7
/**
8
 * Class Terminal
9
 * @author AlecRabbit
10
 */
11
class Terminal extends AbstractTerminal implements TerminalInterface
12
{
13
14
    /** {@inheritdoc} */
15 2
    public function width(bool $recheck = false): int
16
    {
17 2
        if (null !== static::$width && true !== $recheck) {
18 2
            return static::$width;
19
        }
20
        return
21 2
            static::$width = $this->getWidth();
22
    }
23
24
25
    /** {@inheritdoc} */
26 2
    public function height(bool $recheck = false): int
27
    {
28 2
        if (null !== static::$height && true !== $recheck) {
29 2
            return static::$height;
30
        }
31
        return
32 2
            static::$height = $this->getHeight();
33
    }
34
35
    /** {@inheritdoc} */
36 75
    public function supports256Color(bool $recheck = false): bool
37
    {
38 75
        if (null !== static::$supports256Color && true !== $recheck) {
39 74
            return static::$supports256Color;
40
        }
41
        return
42 1
            static::$supports256Color = $this->check256ColorSupport();
43
    }
44
45
    /** {@inheritdoc} */
46 75
    public function supportsColor(): bool
47
    {
48 75
        if (null !== static::$supportsColor) {
49 75
            return static::$supportsColor;
50
        }
51
        return
52 1
            static::$supportsColor = $this->hasColorSupport();
53
    }
54
}
55