Completed
Pull Request — master (#8)
by Amine
01:40
created
src/Template/TemplateLoader.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
      * @throws Tarsana\Command\Exceptions\TemplateNotFound
74 74
      * @throws Tarsana\Command\Exceptions\TemplateNameConflict
75 75
      */
76
-    public function load (string $name) : TemplateInterface
76
+    public function load(string $name) : TemplateInterface
77 77
     {
78 78
         $supportedExtensions = array_keys(self::$providers);
79 79
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,8 +87,9 @@
 block discarded – undo
87 87
         $found = [];
88 88
         foreach ($files as $file) {
89 89
             $ext = $file->extension();
90
-            if (!in_array($ext, $supportedExtensions))
91
-                continue;
90
+            if (!in_array($ext, $supportedExtensions)) {
91
+                            continue;
92
+            }
92 93
             $found[] = [
93 94
                 'name' => substr($file->path(), $fsPathLength),
94 95
                 'extension' => $ext
Please login to merge, or discard this patch.
src/Console/ExceptionPrinter.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
         }
63 63
         if ($s instanceof ArraySyntax) {
64 64
             if ($short) return 'array';
65
-            return $this->printSyntax($s->syntax()).$s->separator().'...';
65
+            return $this->printSyntax($s->syntax()) . $s->separator() . '...';
66 66
         }
67 67
         return (string) $s;
68 68
     }
Please login to merge, or discard this patch.
Braces   +18 added lines, -10 removed lines patch added patch discarded remove patch
@@ -18,8 +18,9 @@  discard block
 block discarded – undo
18 18
      */
19 19
     public function print(\Exception $e) : string
20 20
     {
21
-        if ($e instanceof ParseException)
22
-            return $this->printParseException($e);
21
+        if ($e instanceof ParseException) {
22
+                    return $this->printParseException($e);
23
+        }
23 24
 
24 25
         return "<error>{$e}</error>";
25 26
     }
@@ -36,10 +37,12 @@  discard block
 block discarded – undo
36 37
         $error  = '';
37 38
         if ($syntax instanceof ObjectSyntax) {
38 39
             $i = $e->extra();
39
-            if ($i['type'] == 'invalid-field')
40
-                $error = "{$i['field']} is invalid!";
41
-            if ($i['type'] == 'missing-field')
42
-                $error = "{$i['field']} is missing!";
40
+            if ($i['type'] == 'invalid-field') {
41
+                            $error = "{$i['field']} is invalid!";
42
+            }
43
+            if ($i['type'] == 'missing-field') {
44
+                            $error = "{$i['field']} is missing!";
45
+            }
43 46
             if ($i['type'] == 'additional-items') {
44 47
                 $items = implode($syntax->separator(), $i['items']);
45 48
                 $error = "additional items {$items}";
@@ -48,8 +51,9 @@  discard block
 block discarded – undo
48 51
         $syntax = $this->printSyntax($e->syntax());
49 52
 
50 53
         $output = "<reset>Failed to parse <warn>'{$e->input()}'</warn> as <info>{$syntax}</info>";
51
-        if ('' != $error)
52
-            $output .= " <error>{$error}</error>";
54
+        if ('' != $error) {
55
+                    $output .= " <error>{$error}</error>";
56
+        }
53 57
 
54 58
         $previous = $e->previous();
55 59
         if ($previous) {
@@ -62,11 +66,15 @@  discard block
 block discarded – undo
62 66
     protected function printSyntax(Syntax $s, bool $short = false) : string
63 67
     {
64 68
         if ($s instanceof ObjectSyntax) {
65
-            if ($short) return 'object';
69
+            if ($short) {
70
+                return 'object';
71
+            }
66 72
             return implode($s->separator(), array_keys($s->fields()));
67 73
         }
68 74
         if ($s instanceof ArraySyntax) {
69
-            if ($short) return 'array';
75
+            if ($short) {
76
+                return 'array';
77
+            }
70 78
             return $this->printSyntax($s->syntax()).$s->separator().'...';
71 79
         }
72 80
         return (string) $s;
Please login to merge, or discard this patch.
src/Console/Console.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,24 +41,27 @@
 block discarded – undo
41 41
 
42 42
     public function stdin(ReaderInterface $in = null)
43 43
     {
44
-        if (null === $in)
45
-            return $this->in;
44
+        if (null === $in) {
45
+                    return $this->in;
46
+        }
46 47
         $this->in = $in;
47 48
         return $this;
48 49
     }
49 50
 
50 51
     public function stdout(WriterInterface $out = null)
51 52
     {
52
-        if (null === $out)
53
-            return $this->out;
53
+        if (null === $out) {
54
+                    return $this->out;
55
+        }
54 56
         $this->out = $out;
55 57
         return $this;
56 58
     }
57 59
 
58 60
     public function stderr(WriterInterface $err = null)
59 61
     {
60
-        if (null === $err)
61
-            return $this->err;
62
+        if (null === $err) {
63
+                    return $this->err;
64
+        }
62 65
         $this->err = $err;
63 66
         return $this;
64 67
     }
Please login to merge, or discard this patch.
src/Template/Twig/TwigTemplate.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
      */
17 17
     protected $data;
18 18
 
19
-    public function __construct ($twig)
19
+    public function __construct($twig)
20 20
     {
21 21
         $this->twig = $twig;
22 22
         $this->data = [];
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      * @param  array $data
29 29
      * @return self
30 30
      */
31
-    public function bind (array $data) : TemplateInterface
31
+    public function bind(array $data) : TemplateInterface
32 32
     {
33 33
         $this->data = array_merge($this->data, $data);
34 34
         return $this;
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      *
53 53
      * @return self
54 54
      */
55
-    public function clear () : TemplateInterface
55
+    public function clear() : TemplateInterface
56 56
     {
57 57
         $this->data = [];
58 58
         return $this;
Please login to merge, or discard this patch.
examples/RepeatCommand.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 
5 5
 class RepeatCommand extends Command {
6 6
 
7
-    protected function init ()
7
+    protected function init()
8 8
     {
9 9
         $this->name('Repeat')
10 10
              ->version('1.0.0')
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,8 +19,9 @@
 block discarded – undo
19 19
     protected function execute()
20 20
     {
21 21
         $result = str_repeat($this->args->word, $this->args->count);
22
-        if ($this->option('--upper'))
23
-            $result = strtoupper($result);
22
+        if ($this->option('--upper')) {
23
+                    $result = strtoupper($result);
24
+        }
24 25
         $this->console->line($result);
25 26
     }
26 27
 
Please login to merge, or discard this patch.
examples/RenderCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 
5 5
 class RenderCommand extends Command {
6 6
 
7
-    protected function init ()
7
+    protected function init()
8 8
     {
9 9
         $this->name('Render')
10 10
              ->version('1.0.0')
Please login to merge, or discard this patch.
examples/ListCommand.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 class ListCommand extends Command {
6 6
 
7
-    protected function init ()
7
+    protected function init()
8 8
     {
9 9
         $this->name('List')
10 10
              ->version('1.0.0-alpha')
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
     protected function execute()
15 15
     {
16
-        foreach($this->fs->find('*')->asArray() as $file) {
16
+        foreach ($this->fs->find('*')->asArray() as $file) {
17 17
             $this->console->line($file->name());
18 18
         }
19 19
     }
Please login to merge, or discard this patch.
examples/HelloWorld.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 
5 5
 class HelloWorld extends Command {
6 6
 
7
-    protected function init ()
7
+    protected function init()
8 8
     {
9 9
         $this->name('Hello World')
10 10
              ->version('1.0.0-alpha')
Please login to merge, or discard this patch.
src/Command.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         }
144 144
 
145 145
         $this->options = [];
146
-        foreach($options as $option)
146
+        foreach ($options as $option)
147 147
             $this->options[$option] = false;
148 148
 
149 149
         return $this;
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
     protected function clear()
366 366
     {
367 367
         $this->args = null;
368
-        foreach($this->options as $name => $value) {
368
+        foreach ($this->options as $name => $value) {
369 369
             $this->options[$name] = false;
370 370
         }
371 371
     }
Please login to merge, or discard this patch.
Braces   +32 added lines, -22 removed lines patch added patch discarded remove patch
@@ -36,8 +36,9 @@  discard block
 block discarded – undo
36 36
 
37 37
     public static function create(callable $action = null) {
38 38
         $command = new Command;
39
-        if (null !== $action)
40
-            $command->action($action);
39
+        if (null !== $action) {
40
+                    $command->action($action);
41
+        }
41 42
         return $command;
42 43
     }
43 44
 
@@ -123,8 +124,9 @@  discard block
 block discarded – undo
123 124
      */
124 125
     public function syntax(string $syntax = null)
125 126
     {
126
-        if (null === $syntax)
127
-            return $this->syntax;
127
+        if (null === $syntax) {
128
+                    return $this->syntax;
129
+        }
128 130
 
129 131
         $this->syntax = S::syntax()->parse("{{$syntax}| }");
130 132
         return $this;
@@ -143,8 +145,9 @@  discard block
 block discarded – undo
143 145
         }
144 146
 
145 147
         $this->options = [];
146
-        foreach($options as $option)
147
-            $this->options[$option] = false;
148
+        foreach($options as $option) {
149
+                    $this->options[$option] = false;
150
+        }
148 151
 
149 152
         return $this;
150 153
     }
@@ -157,8 +160,9 @@  discard block
 block discarded – undo
157 160
      */
158 161
     public function option(string $name)
159 162
     {
160
-        if (!array_key_exists($name, $this->options))
161
-            throw new \InvalidArgumentException("Unknown option '{$name}'");
163
+        if (!array_key_exists($name, $this->options)) {
164
+                    throw new \InvalidArgumentException("Unknown option '{$name}'");
165
+        }
162 166
         return $this->options[$name];
163 167
     }
164 168
 
@@ -206,8 +210,9 @@  discard block
 block discarded – undo
206 210
         if (null === $value) {
207 211
             return $this->fs;
208 212
         }
209
-        if (is_string($value))
210
-            $value = new Filesystem($value);
213
+        if (is_string($value)) {
214
+                    $value = new Filesystem($value);
215
+        }
211 216
         $this->fs = $value;
212 217
         foreach ($this->commands as $name => $command) {
213 218
             $command->fs = $value;
@@ -242,8 +247,9 @@  discard block
 block discarded – undo
242 247
     }
243 248
 
244 249
     public function template(string $name) {
245
-        if (null === $this->templatesLoader)
246
-            throw new \Exception("Please initialize the templates loader before trying to load templates!");
250
+        if (null === $this->templatesLoader) {
251
+                    throw new \Exception("Please initialize the templates loader before trying to load templates!");
252
+        }
247 253
         return $this->templatesLoader->load($name);
248 254
     }
249 255
 
@@ -283,8 +289,9 @@  discard block
 block discarded – undo
283 289
     public function command(string $name, Command $command = null)
284 290
     {
285 291
         if (null === $command) {
286
-            if (!array_key_exists($name, $this->commands))
287
-                throw new \InvalidArgumentException("subcommand '{$name}' not found!");
292
+            if (!array_key_exists($name, $this->commands)) {
293
+                            throw new \InvalidArgumentException("subcommand '{$name}' not found!");
294
+            }
288 295
             return $this->commands[$name];
289 296
         }
290 297
         $this->commands[$name] = $command;
@@ -305,9 +312,10 @@  discard block
 block discarded – undo
305 312
 
306 313
     public function describe(string $name, string $description = null)
307 314
     {
308
-        if (null === $description)
309
-            return array_key_exists($name, $this->descriptions)
315
+        if (null === $description) {
316
+                    return array_key_exists($name, $this->descriptions)
310 317
                 ? $this->descriptions[$name] : '';
318
+        }
311 319
         if (substr($name, 0, 2) == '--' && array_key_exists($name, $this->options())) {
312 320
             $this->descriptions[$name] = $description;
313 321
             return $this;
@@ -343,8 +351,9 @@  discard block
 block discarded – undo
343 351
             } else {
344 352
                 $this->args = (object) $args;
345 353
                 foreach ($options as $name) {
346
-                    if (!array_key_exists($name, $this->options))
347
-                        throw new \Exception("Unknown option '{$name}'");
354
+                    if (!array_key_exists($name, $this->options)) {
355
+                                            throw new \Exception("Unknown option '{$name}'");
356
+                    }
348 357
                     $this->options[$name] = true;
349 358
                 }
350 359
             }
@@ -379,10 +388,11 @@  discard block
 block discarded – undo
379 388
 
380 389
         $arguments = [];
381 390
         foreach ($args as &$arg) {
382
-            if (array_key_exists($arg, $this->options))
383
-                $this->options[$arg] = true;
384
-            else
385
-                $arguments[] = $arg;
391
+            if (array_key_exists($arg, $this->options)) {
392
+                            $this->options[$arg] = true;
393
+            } else {
394
+                            $arguments[] = $arg;
395
+            }
386 396
         }
387 397
         $arguments = T::join($arguments, ' ');
388 398
         $this->args = $this->syntax->parse($arguments);
Please login to merge, or discard this patch.