Test Setup Failed
Branch master (816c76)
by Alec
04:22
created

Terminal::initDimensions()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 3
nop 0
dl 0
loc 6
ccs 0
cts 0
cp 0
crap 12
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
    public function width(bool $recheck = false): int
16
    {
17
        if (null !== static::$width && true !== $recheck) {
18
            return static::$width;
19
        }
20
        return
21
            static::$width = $this->getWidth();
22
    }
23
24
25
    /** {@inheritdoc} */
26
    public function height(bool $recheck = false): int
27
    {
28
        if (null !== static::$height && true !== $recheck) {
29
            return static::$height;
30
        }
31
        return
32
            static::$height = $this->getHeight();
33
    }
34
35 2
    /** {@inheritdoc} */
36
    public function supports256Color(bool $recheck = false): bool
37 2
    {
38 2
        if (null !== static::$supports256Color && true !== $recheck) {
39
            return static::$supports256Color;
40
        }
41 2
        return
42
            static::$supports256Color = $this->check256ColorSupport();
43
    }
44
45
    /** {@inheritdoc} */
46
    public function supportsColor(): bool
47
    {
48
        if (null !== static::$supportsColor) {
49 2
            return static::$supportsColor;
50
        }
51 2
        return
52 2
            static::$supportsColor = $this->hasColorSupport();
53 2
    }
54
}
55