Total Complexity | 9 |
Total Lines | 66 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | abstract class CmdRunner { |
||
8 | |||
9 | /** |
||
10 | * @var Cmd |
||
11 | */ |
||
12 | private $cmd; |
||
13 | |||
14 | /** |
||
15 | * CmdRunner constructor. |
||
16 | * @param Cmd $cmd |
||
17 | */ |
||
18 | 21 | public function __construct(Cmd $cmd = null) { |
|
24 | 21 | } |
|
25 | |||
26 | /** |
||
27 | * @param Cmd $cmd |
||
28 | */ |
||
29 | 21 | public function init(Cmd $cmd): void { |
|
30 | 21 | $this->cmd = $cmd; |
|
31 | 21 | } |
|
32 | |||
33 | /** |
||
34 | * @return Cmd |
||
35 | */ |
||
36 | 5 | public function getCmd(): Cmd { |
|
37 | 5 | return $this->cmd; |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * Run the cmd |
||
42 | */ |
||
43 | abstract public function run(): void; |
||
44 | |||
45 | /** |
||
46 | * Overwrite this method for extended help |
||
47 | */ |
||
48 | 3 | public function help(): void { |
|
49 | |||
50 | 3 | } |
|
51 | |||
52 | |||
53 | public const EOL = "\n"; |
||
54 | |||
55 | |||
56 | 6 | public static function eol(): void { |
|
58 | 6 | } |
|
59 | |||
60 | 6 | public static function echo(string $str, ?string $foreground_color = null): void { |
|
73 | 6 | } |
|
74 | |||
75 | } |