@@ -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; |
@@ -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 |
@@ -84,10 +84,11 @@ |
||
84 | 84 | { |
85 | 85 | $tabs = str_repeat('<tab>', $level); |
86 | 86 | $optional = ($s instanceof OptionalSyntax); |
87 | - if ($optional) |
|
88 | - $default = 'default: ' . json_encode($s->getDefault()); |
|
89 | - else |
|
90 | - $default = 'required'; |
|
87 | + if ($optional) { |
|
88 | + $default = 'default: ' . json_encode($s->getDefault()); |
|
89 | + } else { |
|
90 | + $default = 'required'; |
|
91 | + } |
|
91 | 92 | $description = $this->parent()->describe($prefix.$name); |
92 | 93 | $syntax = $this->helper->asString($s); |
93 | 94 | $text = "{$tabs}<warn>{$name}</warn> <success>{$syntax}</success>" |
@@ -9,8 +9,9 @@ discard block |
||
9 | 9 | |
10 | 10 | public static function instance() : SyntaxHelper |
11 | 11 | { |
12 | - if (null === self::$instance) |
|
13 | - self::$instance = new SyntaxHelper; |
|
12 | + if (null === self::$instance) { |
|
13 | + self::$instance = new SyntaxHelper; |
|
14 | + } |
|
14 | 15 | return self::$instance; |
15 | 16 | } |
16 | 17 | |
@@ -25,8 +26,9 @@ discard block |
||
25 | 26 | public function asString(Syntax $syntax) : string |
26 | 27 | { |
27 | 28 | $type = $this->type($syntax); |
28 | - if ($type == 'optional') |
|
29 | - return $this->asString($syntax->syntax()); |
|
29 | + if ($type == 'optional') { |
|
30 | + return $this->asString($syntax->syntax()); |
|
31 | + } |
|
30 | 32 | switch ($type) { |
31 | 33 | case 'object': |
32 | 34 | return implode( |
@@ -104,8 +104,9 @@ discard block |
||
104 | 104 | protected function readObject(ObjectSyntax $syntax, string $prefix) |
105 | 105 | { |
106 | 106 | $result = []; |
107 | - if ($prefix != '') |
|
108 | - $prefix .= '.'; |
|
107 | + if ($prefix != '') { |
|
108 | + $prefix .= '.'; |
|
109 | + } |
|
109 | 110 | foreach ($syntax->fields() as $name => $s) { |
110 | 111 | $fullname = $prefix . $name; |
111 | 112 | $result[$name] = $this->read($s, $fullname, true); |
@@ -132,8 +133,9 @@ discard block |
||
132 | 133 | $this->console->out("<color:252>{$default}<column:1><reset>"); |
133 | 134 | $n = ord($this->console->char()); |
134 | 135 | $this->console->out('<column:1><clearLine>'); |
135 | - if (array_key_exists($n, static::KEYS) && static::KEYS[$n] == 'enter') |
|
136 | - return $syntax->getDefault(); |
|
136 | + if (array_key_exists($n, static::KEYS) && static::KEYS[$n] == 'enter') { |
|
137 | + return $syntax->getDefault(); |
|
138 | + } |
|
137 | 139 | return $this->read($syntax->syntax(), $prefix); |
138 | 140 | } |
139 | 141 | |
@@ -175,8 +177,9 @@ discard block |
||
175 | 177 | protected function readChar() : string |
176 | 178 | { |
177 | 179 | $c = $this->console->char(); |
178 | - if (ctype_print($c)) |
|
179 | - return $c; |
|
180 | + if (ctype_print($c)) { |
|
181 | + return $c; |
|
182 | + } |
|
180 | 183 | $n = ord($c); |
181 | 184 | if ( |
182 | 185 | array_key_exists($n, static::KEYS) |
@@ -22,13 +22,15 @@ |
||
22 | 22 | */ |
23 | 23 | public function get(string $path = null) |
24 | 24 | { |
25 | - if (null === $path) |
|
26 | - return $this->data; |
|
25 | + if (null === $path) { |
|
26 | + return $this->data; |
|
27 | + } |
|
27 | 28 | $keys = explode('.', $path); |
28 | 29 | $value = $this->data; |
29 | 30 | foreach ($keys as $key) { |
30 | - if (!is_array($value) || !array_key_exists($key, $value)) |
|
31 | - throw new \Exception("Unable to find a configuration value with path '{$path}'"); |
|
31 | + if (!is_array($value) || !array_key_exists($key, $value)) { |
|
32 | + throw new \Exception("Unable to find a configuration value with path '{$path}'"); |
|
33 | + } |
|
32 | 34 | $value = $value[$key]; |
33 | 35 | } |
34 | 36 | return $value; |
@@ -24,8 +24,9 @@ discard block |
||
24 | 24 | |
25 | 25 | public function load(array $paths) : ConfigInterface |
26 | 26 | { |
27 | - if (empty($paths)) |
|
28 | - return new Config([]); |
|
27 | + if (empty($paths)) { |
|
28 | + return new Config([]); |
|
29 | + } |
|
29 | 30 | $data = []; |
30 | 31 | foreach ($paths as $path) { |
31 | 32 | $data[] = $this->decode($path); |
@@ -35,12 +36,14 @@ discard block |
||
35 | 36 | } |
36 | 37 | |
37 | 38 | protected function decode(string $path) : array { |
38 | - if (! $this->fs->isFile($path)) |
|
39 | - return []; |
|
39 | + if (! $this->fs->isFile($path)) { |
|
40 | + return []; |
|
41 | + } |
|
40 | 42 | $file = $this->fs->file($path); |
41 | 43 | $ext = $file->extension(); |
42 | - if (! array_key_exists($ext, static::$decoders)) |
|
43 | - throw new \Exception("Unknown configuration file extension '{$ext}'"); |
|
44 | + if (! array_key_exists($ext, static::$decoders)) { |
|
45 | + throw new \Exception("Unknown configuration file extension '{$ext}'"); |
|
46 | + } |
|
44 | 47 | $decoderClass = static::$decoders[$ext]; |
45 | 48 | $decoder = new $decoderClass; |
46 | 49 | return $decoder->decode($file->content()); |