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

App::echo()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 8
c 0
b 0
f 0
nc 3
nop 2
dl 0
loc 13
ccs 0
cts 10
cp 0
crap 12
rs 10
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
}