Passed
Branch master (911f86)
by Timm
01:57
created

App   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A eol() 0 2 1
A echo() 0 13 3
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
    public static function eol(): void {
17
        echo self::EOL;
18
    }
19
20
    public static function echo(string $str, ?string $foreground_color = null): void {
21
22
        $lines = preg_split("/\r\n|\n|\r/", $str);
23
24
        $output = [];
25
        foreach ($lines as $line) {
26
            if ($foreground_color !== null) {
27
                $line = Color::getColoredString($line, $foreground_color);
28
            }
29
            $output[] = $line;
30
        }
31
32
        echo implode(self::EOL, $output);
33
    }
34
35
36
}