Passed
Push — master ( f31d6e...f89447 )
by Timm
01:52
created

App   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 26
ccs 11
cts 11
cp 1
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A echo() 0 13 3
A eol() 0 2 1
1
<?php
2
3
4
namespace Stefaminator\Cli;
5
6
7
abstract class App {
8
9
    public const EOL = "\n";
10
11
    /**
12
     * @return Cmd
13
     */
14
    abstract public function setup(): Cmd;
15
16 1
    public static function eol(): void {
17 1
        echo self::EOL;
18 1
    }
19
20 1
    public static function echo(string $str, ?string $foreground_color = null): void {
21
22 1
        $lines = preg_split("/\r\n|\n|\r/", $str);
23
24 1
        $output = [];
25 1
        foreach ($lines as $line) {
26 1
            if ($foreground_color !== null) {
27 1
                $line = Color::getColoredString($line, $foreground_color);
28
            }
29 1
            $output[] = $line;
30
        }
31
32 1
        echo implode(self::EOL, $output);
33 1
    }
34
35
36
}