System::hasAnsiSupport()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 3
cts 4
cp 0.75
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2.0625
1
<?php
2
3
namespace League\CLImate\Util\System;
4
5
abstract class System
6
{
7
    protected $force_ansi;
8
9
    /**
10
     * Force ansi on or off
11
     *
12
     * @param bool $force
13
     */
14 8
    public function forceAnsi($force = true)
15
    {
16 8
        $this->force_ansi = $force;
17 8
    }
18
19
    /**
20
     * @return integer|null
21
     */
22
    abstract public function width();
23
24
    /**
25
     * @return integer|null
26
     */
27
    abstract public function height();
28
29
    /**
30
     * Check if the stream supports ansi escape characters.
31
     *
32
     * @return bool
33
     */
34
    abstract protected function systemHasAnsiSupport();
35
36
    /**
37
     * Check if we are forcing ansi, fallback to system support
38
     *
39
     * @return bool
40
     */
41 8
    public function hasAnsiSupport()
42
    {
43 8
        if (is_bool($this->force_ansi)) {
44 8
            return $this->force_ansi;
45
        }
46
47
        return $this->systemHasAnsiSupport();
48
    }
49
50
    /**
51
     * Wraps exec function, allowing the dimension methods to decouple
52
     *
53
     * @param string $command
54
     * @param boolean $full
55
     *
56
     * @return string|array
57
     */
58
    public function exec($command, $full = false)
59
    {
60
        if ($full) {
61
            exec($command, $output);
62
63
            return $output;
64
        }
65
66
        return exec($command);
67
    }
68
}
69