@@ -87,8 +87,9 @@ |
||
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 |
@@ -41,24 +41,27 @@ |
||
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 | } |
@@ -18,8 +18,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -7,13 +7,13 @@ |
||
7 | 7 | protected function init () |
8 | 8 | { |
9 | 9 | $this->name('Repeat') |
10 | - ->version('1.0.0') |
|
11 | - ->description('Repeats a word a number of times') |
|
12 | - ->syntax('word: string, count: (number: 3)') |
|
13 | - ->options(['--upper']) |
|
14 | - ->describe('word', 'The word to repeat') |
|
15 | - ->describe('count', 'The number of times to repeat the word') |
|
16 | - ->describe('--upper', 'Converts the result to uppercase'); |
|
10 | + ->version('1.0.0') |
|
11 | + ->description('Repeats a word a number of times') |
|
12 | + ->syntax('word: string, count: (number: 3)') |
|
13 | + ->options(['--upper']) |
|
14 | + ->describe('word', 'The word to repeat') |
|
15 | + ->describe('count', 'The number of times to repeat the word') |
|
16 | + ->describe('--upper', 'Converts the result to uppercase'); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | protected function execute() |
@@ -19,8 +19,9 @@ |
||
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 |
@@ -7,12 +7,12 @@ |
||
7 | 7 | protected function init () |
8 | 8 | { |
9 | 9 | $this->name('Render') |
10 | - ->version('1.0.0') |
|
11 | - ->description('Renders the hello template.') |
|
12 | - ->syntax('name: (string:You)') |
|
13 | - ->describe('name', 'Your name.') |
|
14 | - ->templatesPath(TEMPLATES_PATH); |
|
15 | - // this points to /tests/resources/templates |
|
10 | + ->version('1.0.0') |
|
11 | + ->description('Renders the hello template.') |
|
12 | + ->syntax('name: (string:You)') |
|
13 | + ->describe('name', 'Your name.') |
|
14 | + ->templatesPath(TEMPLATES_PATH); |
|
15 | + // this points to /tests/resources/templates |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | protected function execute() |
@@ -7,8 +7,8 @@ |
||
7 | 7 | protected function init () |
8 | 8 | { |
9 | 9 | $this->name('List') |
10 | - ->version('1.0.0-alpha') |
|
11 | - ->description('Lists files and directories in the current directory.'); |
|
10 | + ->version('1.0.0-alpha') |
|
11 | + ->description('Lists files and directories in the current directory.'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | protected function execute() |
@@ -9,16 +9,16 @@ |
||
9 | 9 | public function test_it_list_files_and_directories() |
10 | 10 | { |
11 | 11 | $this->havingFile('demo.txt', 'Some text here!') |
12 | - ->havingFile('doc.pdf') |
|
13 | - ->havingDir('src') |
|
14 | - ->command(new ListCommand) |
|
15 | - ->printsExactly('demo.txt<br>doc.pdf<br>src<br>'); |
|
12 | + ->havingFile('doc.pdf') |
|
13 | + ->havingDir('src') |
|
14 | + ->command(new ListCommand) |
|
15 | + ->printsExactly('demo.txt<br>doc.pdf<br>src<br>'); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | public function test_it_prints_nothing_when_no_files() |
19 | 19 | { |
20 | 20 | $this->command(new ListCommand) |
21 | - ->printsExactly(''); |
|
21 | + ->printsExactly(''); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | } |
@@ -9,12 +9,12 @@ |
||
9 | 9 | public function test_it_renders_the_template() |
10 | 10 | { |
11 | 11 | $this->command(new RenderCommand) |
12 | - ->printsExactly("Hello You<br>"); |
|
12 | + ->printsExactly("Hello You<br>"); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | public function test_it_renders_with_custom_name() |
16 | 16 | { |
17 | 17 | $this->command(new RenderCommand, ['Foo']) |
18 | - ->printsExactly("Hello Foo<br>"); |
|
18 | + ->printsExactly("Hello Foo<br>"); |
|
19 | 19 | } |
20 | 20 | } |
@@ -9,54 +9,54 @@ |
||
9 | 9 | public function test_it_repeats_word_three_times() |
10 | 10 | { |
11 | 11 | $this->command(new RepeatCommand, ['foo']) |
12 | - ->argsEqual((object) [ |
|
12 | + ->argsEqual((object) [ |
|
13 | 13 | 'word' => 'foo', |
14 | 14 | 'count' => 3 |
15 | - ]) |
|
16 | - ->optionsEqual([ |
|
15 | + ]) |
|
16 | + ->optionsEqual([ |
|
17 | 17 | '--upper' => false |
18 | - ]) |
|
19 | - ->printsExactly("foofoofoo<br>"); |
|
18 | + ]) |
|
19 | + ->printsExactly("foofoofoo<br>"); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function test_it_repeats_word_n_times() |
23 | 23 | { |
24 | 24 | $this->command(new RepeatCommand, ['bar', '5']) |
25 | - ->argsEqual((object) [ |
|
25 | + ->argsEqual((object) [ |
|
26 | 26 | 'word' => 'bar', |
27 | 27 | 'count' => 5 |
28 | - ]) |
|
29 | - ->optionsEqual([ |
|
28 | + ]) |
|
29 | + ->optionsEqual([ |
|
30 | 30 | '--upper' => false |
31 | - ]) |
|
32 | - ->printsExactly("barbarbarbarbar<br>"); |
|
31 | + ]) |
|
32 | + ->printsExactly("barbarbarbarbar<br>"); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function test_it_repeats_word_n_times_uppercase() |
36 | 36 | { |
37 | 37 | $this->command(new RepeatCommand, ['bar', '5', '--upper']) |
38 | - ->argsEqual((object) [ |
|
39 | - 'word' => 'bar', |
|
40 | - 'count' => 5 |
|
41 | - ]) |
|
42 | - ->optionsEqual([ |
|
43 | - '--upper' => true |
|
44 | - ]) |
|
45 | - ->printsExactly("BARBARBARBARBAR<br>"); |
|
38 | + ->argsEqual((object) [ |
|
39 | + 'word' => 'bar', |
|
40 | + 'count' => 5 |
|
41 | + ]) |
|
42 | + ->optionsEqual([ |
|
43 | + '--upper' => true |
|
44 | + ]) |
|
45 | + ->printsExactly("BARBARBARBARBAR<br>"); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | public function test_it_runs_interatively() |
49 | 49 | { |
50 | 50 | $this->withStdin("Yo\n\n\n") |
51 | - ->command(new RepeatCommand, ['-i']) |
|
52 | - ->argsEqual((object) [ |
|
53 | - 'word' => 'Yo', |
|
54 | - 'count' => 3 |
|
55 | - ]) |
|
56 | - ->optionsEqual([ |
|
57 | - '--upper' => false |
|
58 | - ]) |
|
59 | - ->prints("YoYoYo<br>"); |
|
51 | + ->command(new RepeatCommand, ['-i']) |
|
52 | + ->argsEqual((object) [ |
|
53 | + 'word' => 'Yo', |
|
54 | + 'count' => 3 |
|
55 | + ]) |
|
56 | + ->optionsEqual([ |
|
57 | + '--upper' => false |
|
58 | + ]) |
|
59 | + ->prints("YoYoYo<br>"); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | } |