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

Terminal   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 42
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0
wmc 11

4 Methods

Rating   Name   Duplication   Size   Complexity  
A supportsColor() 0 7 2
A supports256Color() 0 7 3
A height() 0 7 3
A width() 0 7 3
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