System   A
last analyzed

↳ Parent: Project

Coupling/Cohesion

Components 1
Dependencies 0

Complexity

Total Complexity 5

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 64
ccs 6
cts 12
cp 0.5
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A forceAnsi() 0 4 1
width() 0 1 ?
height() 0 1 ?
systemHasAnsiSupport() 0 1 ?
A hasAnsiSupport() 0 8 2
A exec() 0 10 2
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