Passed
Branch master (74eb15)
by Timm
02:00
created
examples/cli-app-helloworld.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@
 block discarded – undo
10 10
 AppParser::run(
11 11
     (new class extends App {
12 12
 
13
-        public function setup(): Cmd {
13
+        public function setup (): Cmd {
14 14
             return Cmd::root()
15
-                ->setCallable(static function (Cmd $cmd) {
15
+                ->setCallable(static function(Cmd $cmd) {
16 16
                     echo 'Hello World' . self::EOL;
17 17
                 });
18 18
         }
Please login to merge, or discard this patch.
examples/cli-app-subcommands.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
 AppParser::run(
12 12
     new class extends App {
13 13
 
14
-        public function setup(): Cmd {
14
+        public function setup (): Cmd {
15 15
             return Cmd::root()
16
-                ->setCallable(static function (Cmd $cmd) {
16
+                ->setCallable(static function(Cmd $cmd) {
17 17
                     $cmd->help();
18 18
                 })
19 19
                 ->addSubCmd(
20 20
                     Cmd::extend('show')
21 21
                         ->setDescription('This command is used to show something. Take a look at the subcommands.')
22
-                        ->setCallable(static function (Cmd $cmd) {
22
+                        ->setCallable(static function(Cmd $cmd) {
23 23
                             error_reporting(E_ALL);
24 24
                             $cmd->help();
25 25
                         })
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
                                     'isa' => 'string',
32 32
                                     'default' => 'World'
33 33
                                 ])
34
-                                ->setCallable(static function (Cmd $cmd) {
34
+                                ->setCallable(static function(Cmd $cmd) {
35 35
 
36 36
 
37 37
                                     $name = $cmd->getProvidedOption('name');
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
                         ->addSubCmd(
46 46
                             Cmd::extend('phpversion')
47 47
                                 ->setDescription('Displays the current php version of your cli.')
48
-                                ->setCallable(static function (Cmd $cmd) {
48
+                                ->setCallable(static function(Cmd $cmd) {
49 49
                                     self::eol();
50 50
                                     self::echo('  Your PHP version is:', Color::FOREGROUND_COLOR_YELLOW);
51 51
                                     self::eol();
Please login to merge, or discard this patch.
examples/cli-app-options.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 AppParser::run(
12 12
     (new class extends App {
13 13
 
14
-        public function setup(): Cmd {
14
+        public function setup (): Cmd {
15 15
             return Cmd::root()
16 16
                 ->addOption('v|verbose', [
17 17
                     'description' => 'Flag to enable verbose output'
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
                     'isa' => 'string',
22 22
                     'default' => 'World'
23 23
                 ])
24
-                ->setCallable(static function (Cmd $cmd) {
24
+                ->setCallable(static function(Cmd $cmd) {
25 25
 
26 26
                     $name = $cmd->getProvidedOption('name');
27 27
 
Please login to merge, or discard this patch.
src/Stefaminator/Cli/CmdRunner.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,19 +15,19 @@
 block discarded – undo
15 15
      * CmdRunner constructor.
16 16
      * @param Cmd $cmd
17 17
      */
18
-    public function __construct(Cmd $cmd) {
18
+    public function __construct (Cmd $cmd) {
19 19
         $this->cmd = $cmd;
20 20
     }
21 21
 
22 22
     /**
23 23
      * @return Cmd
24 24
      */
25
-    public function cmd(): Cmd {
25
+    public function cmd (): Cmd {
26 26
         return $this->cmd;
27 27
     }
28 28
 
29 29
     /**
30 30
      * Run the cmd
31 31
      */
32
-    abstract public function run(): void;
32
+    abstract public function run (): void;
33 33
 }
34 34
\ No newline at end of file
Please login to merge, or discard this patch.
src/Stefaminator/Cli/App.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@
 block discarded – undo
11 11
     /**
12 12
      * @return Cmd
13 13
      */
14
-    abstract public function setup(): Cmd;
14
+    abstract public function setup (): Cmd;
15 15
 
16
-    public static function eol(): void {
16
+    public static function eol (): void {
17 17
         echo self::EOL;
18 18
     }
19 19
 
20
-    public static function echo(string $str, ?string $foreground_color = null): void {
20
+    public static function echo(string $str, ?string $foreground_color = null) : void {
21 21
 
22 22
         $lines = preg_split("/\r\n|\n|\r/", $str);
23 23
 
Please login to merge, or discard this patch.
src/Stefaminator/Cli/Color.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     public const BACKGROUND_COLOR_CYAN = '46';
33 33
     public const BACKGROUND_COLOR_LIGHT_GRAY = '47';
34 34
 
35
-    public static function getForegroundColors(): array {
35
+    public static function getForegroundColors (): array {
36 36
         return [
37 37
             self::FOREGROUND_COLOR_BLACK => 'BLACK',
38 38
             self::FOREGROUND_COLOR_DARK_GRAY => 'DARK_GRAY',
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         ];
54 54
     }
55 55
 
56
-    public static function getBackgroundColors(): array {
56
+    public static function getBackgroundColors (): array {
57 57
         return [
58 58
             self::BACKGROUND_COLOR_BLACK => 'BLACK',
59 59
             self::BACKGROUND_COLOR_RED => 'RED',
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     }
68 68
 
69 69
     // Returns colored string
70
-    public static function getColoredString($string, $foreground_color = null, $background_color = null): string {
70
+    public static function getColoredString ($string, $foreground_color = null, $background_color = null): string {
71 71
 
72 72
         if (empty($string)) {
73 73
             return '';
@@ -94,23 +94,23 @@  discard block
 block discarded – undo
94 94
         echo self::getColoredString($string, $foreground_color, $background_color);
95 95
     }
96 96
 
97
-    public static function red($string): void {
97
+    public static function red ($string): void {
98 98
         echo self::getColoredString($string, self::FOREGROUND_COLOR_RED);
99 99
     }
100 100
 
101
-    public static function green($string): void {
101
+    public static function green ($string): void {
102 102
         echo self::getColoredString($string, self::FOREGROUND_COLOR_GREEN);
103 103
     }
104 104
 
105
-    public static function blue($string): void {
105
+    public static function blue ($string): void {
106 106
         echo self::getColoredString($string, self::FOREGROUND_COLOR_BLUE);
107 107
     }
108 108
 
109
-    public static function yellow($string): void {
109
+    public static function yellow ($string): void {
110 110
         echo self::getColoredString($string, self::FOREGROUND_COLOR_YELLOW);
111 111
     }
112 112
 
113
-    public static function purple($string): void {
113
+    public static function purple ($string): void {
114 114
         echo self::getColoredString($string, self::FOREGROUND_COLOR_PURPLE);
115 115
     }
116 116
 
Please login to merge, or discard this patch.
src/Stefaminator/Cli/Progress.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
 class Progress {
8 8
 
9 9
 
10
-    public static function showStatus(int $done, int $total, int $size = 30): void {
10
+    public static function showStatus (int $done, int $total, int $size = 30): void {
11 11
 
12 12
         static $start_time = NULL;
13 13
 
Please login to merge, or discard this patch.
src/Stefaminator/Cli/AppParser.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 class AppParser {
12 12
 
13
-    public static function run(App $app): void {
13
+    public static function run (App $app): void {
14 14
         global $argv;
15 15
 
16 16
         try {
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
                     return;
23 23
                 }
24 24
 
25
-                if(self::callCallable($cmd)) {
25
+                if (self::callCallable($cmd)) {
26 26
                     return;
27 27
                 }
28 28
 
29
-                if(self::callMethod($app, $cmd)) {
29
+                if (self::callMethod($app, $cmd)) {
30 30
                     return;
31 31
                 }
32 32
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @return bool
48 48
      * @throws Exception
49 49
      */
50
-    private static function callCallable(Cmd $cmd): bool {
50
+    private static function callCallable (Cmd $cmd): bool {
51 51
 
52 52
         $callable = $cmd->getCallable();
53 53
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      * @return bool
66 66
      * @throws Exception
67 67
      */
68
-    private static function callMethod(App $app, Cmd $cmd): bool {
68
+    private static function callMethod (App $app, Cmd $cmd): bool {
69 69
 
70 70
         $methodName = $cmd->getMethodName();
71 71
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      * @param array $argv
83 83
      * @return Cmd
84 84
      */
85
-    public static function route(App $app, array $argv): Cmd {
85
+    public static function route (App $app, array $argv): Cmd {
86 86
 
87 87
         $cmd = $app->setup();
88 88
 
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
             if ($cmd->hasSubCmd($currentArgument)) {
106 106
                 $_cmd = $cmd->getSubCmd($currentArgument);
107 107
 
108
-                if($_cmd !== null) {
108
+                if ($_cmd !== null) {
109 109
                     $subcommand = $_cmd;
110 110
                 }
111 111
             }
112 112
 
113
-            if($subcommand !== null) {
113
+            if ($subcommand !== null) {
114 114
 
115 115
                 $cmd = $subcommand;
116 116
                 $parser->advance();
Please login to merge, or discard this patch.
src/Stefaminator/Cli/HelpRunner.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
7 7
 class HelpRunner extends CmdRunner {
8 8
 
9 9
 
10
-    public function run(): void {
10
+    public function run (): void {
11 11
         $this->displayHeader();
12 12
         $this->displayUsage();
13 13
         $this->displayOptions();
14 14
         $this->displaySubcommands();
15 15
     }
16 16
 
17
-    public function displayHeader(): void {
17
+    public function displayHeader (): void {
18 18
 
19 19
 
20 20
         $help = <<<EOT
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
         App::eol();
33 33
     }
34 34
 
35
-    public function displayUsage(): void {
35
+    public function displayUsage (): void {
36 36
 
37 37
         $cmd = $this->cmd();
38 38
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         App::eol();
56 56
     }
57 57
 
58
-    public function displayOptions(): void {
58
+    public function displayOptions (): void {
59 59
 
60 60
         $cmd = $this->cmd();
61 61
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
             foreach ($oc->options as $option) {
72 72
 
73 73
                 $s = '    ';
74
-                if(!empty($option->short)) {
74
+                if (!empty($option->short)) {
75 75
                     $s = '-' . $option->short . ', ';
76 76
                 }
77 77
                 $s .= '--' . $option->long;
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
 
96 96
     }
97 97
 
98
-    public function displaySubcommands(): void {
98
+    public function displaySubcommands (): void {
99 99
 
100 100
         $cmd = $this->cmd();
101 101
 
102 102
         $has_subcommands = !empty($cmd->subcommands);
103 103
 
104
-        if($has_subcommands) {
104
+        if ($has_subcommands) {
105 105
 
106 106
             App::eol();
107 107
             App::echo('Available commands: ', Color::FOREGROUND_COLOR_YELLOW);
Please login to merge, or discard this patch.