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

App::eol()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 2
ccs 0
cts 2
cp 0
crap 2
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
}