@@ -31,10 +31,10 @@ |
||
31 | 31 | */ |
32 | 32 | public function render(int $indentLevel = 0): string |
33 | 33 | { |
34 | - if (empty($this->directives)) { |
|
34 | + if (empty($this->directives)){ |
|
35 | 35 | return ''; |
36 | 36 | } |
37 | 37 | |
38 | - return 'declare(' . implode(', ', $this->directives) . ');'; |
|
38 | + return 'declare('.implode(', ', $this->directives).');'; |
|
39 | 39 | } |
40 | 40 | } |
@@ -31,7 +31,8 @@ |
||
31 | 31 | */ |
32 | 32 | public function render(int $indentLevel = 0): string |
33 | 33 | { |
34 | - if (empty($this->directives)) { |
|
34 | + if (empty($this->directives)) |
|
35 | + { |
|
35 | 36 | return ''; |
36 | 37 | } |
37 | 38 |
@@ -101,10 +101,14 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function setSource($source): Method |
103 | 103 | { |
104 | - if (!empty($source)) { |
|
105 | - if (is_array($source)) { |
|
104 | + if (!empty($source)) |
|
105 | + { |
|
106 | + if (is_array($source)) |
|
107 | + { |
|
106 | 108 | $this->source->setLines($source); |
107 | - } elseif (is_string($source)) { |
|
109 | + } |
|
110 | + elseif (is_string($source)) |
|
111 | + { |
|
108 | 112 | $this->source->setString($source); |
109 | 113 | } |
110 | 114 | } |
@@ -147,25 +151,31 @@ discard block |
||
147 | 151 | public function render(int $indentLevel = 0): string |
148 | 152 | { |
149 | 153 | $result = ''; |
150 | - if (!$this->docComment->isEmpty()) { |
|
154 | + if (!$this->docComment->isEmpty()) |
|
155 | + { |
|
151 | 156 | $result .= $this->docComment->render($indentLevel) . "\n"; |
152 | 157 | } |
153 | 158 | |
154 | 159 | $method = $this->renderModifiers(); |
155 | - if (!$this->parameters->isEmpty()) { |
|
160 | + if (!$this->parameters->isEmpty()) |
|
161 | + { |
|
156 | 162 | $method .= "({$this->parameters->render()})"; |
157 | - } else { |
|
163 | + } |
|
164 | + else |
|
165 | + { |
|
158 | 166 | $method .= '()'; |
159 | 167 | } |
160 | 168 | |
161 | - if ($this->return) { |
|
169 | + if ($this->return) |
|
170 | + { |
|
162 | 171 | $method .= ": {$this->return}"; |
163 | 172 | } |
164 | 173 | |
165 | 174 | $result .= $this->addIndent($method, $indentLevel) . "\n"; |
166 | 175 | $result .= $this->addIndent('{', $indentLevel) . "\n"; |
167 | 176 | |
168 | - if (!$this->source->isEmpty()) { |
|
177 | + if (!$this->source->isEmpty()) |
|
178 | + { |
|
169 | 179 | $result .= $this->source->render($indentLevel + 1) . "\n"; |
170 | 180 | } |
171 | 181 | |
@@ -181,7 +191,8 @@ discard block |
||
181 | 191 | { |
182 | 192 | $chunks = [$this->getAccess()]; |
183 | 193 | |
184 | - if ($this->isStatic()) { |
|
194 | + if ($this->isStatic()) |
|
195 | + { |
|
185 | 196 | $chunks[] = 'static'; |
186 | 197 | } |
187 | 198 | |
@@ -197,14 +208,19 @@ discard block |
||
197 | 208 | */ |
198 | 209 | private function initSource($source): void |
199 | 210 | { |
200 | - if (empty($this->source)) { |
|
211 | + if (empty($this->source)) |
|
212 | + { |
|
201 | 213 | $this->source = new Source(); |
202 | 214 | } |
203 | 215 | |
204 | - if (!empty($source)) { |
|
205 | - if (is_array($source)) { |
|
216 | + if (!empty($source)) |
|
217 | + { |
|
218 | + if (is_array($source)) |
|
219 | + { |
|
206 | 220 | $this->source->setLines($source); |
207 | - } elseif (is_string($source)) { |
|
221 | + } |
|
222 | + elseif (is_string($source)) |
|
223 | + { |
|
208 | 224 | $this->source->setString($source); |
209 | 225 | } |
210 | 226 | } |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function setSource($source): Method |
88 | 88 | { |
89 | - if (!empty($source)) { |
|
90 | - if (is_array($source)) { |
|
89 | + if (!empty($source)){ |
|
90 | + if (is_array($source)){ |
|
91 | 91 | $this->source->setLines($source); |
92 | - } elseif (is_string($source)) { |
|
92 | + } elseif (is_string($source)){ |
|
93 | 93 | $this->source->setString($source); |
94 | 94 | } |
95 | 95 | } |
@@ -123,36 +123,36 @@ discard block |
||
123 | 123 | public function render(int $indentLevel = 0): string |
124 | 124 | { |
125 | 125 | $result = ''; |
126 | - if (!$this->docComment->isEmpty()) { |
|
127 | - $result .= $this->docComment->render($indentLevel) . "\n"; |
|
126 | + if (!$this->docComment->isEmpty()){ |
|
127 | + $result .= $this->docComment->render($indentLevel)."\n"; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | $method = $this->renderModifiers(); |
131 | - if (!$this->parameters->isEmpty()) { |
|
131 | + if (!$this->parameters->isEmpty()){ |
|
132 | 132 | $method .= "({$this->parameters->render()})"; |
133 | - } else { |
|
133 | + }else{ |
|
134 | 134 | $method .= '()'; |
135 | 135 | } |
136 | 136 | |
137 | - if ($this->return) { |
|
137 | + if ($this->return){ |
|
138 | 138 | $method .= ": {$this->return}"; |
139 | 139 | } |
140 | 140 | |
141 | - $result .= $this->addIndent($method, $indentLevel) . "\n"; |
|
142 | - $result .= $this->addIndent('{', $indentLevel) . "\n"; |
|
141 | + $result .= $this->addIndent($method, $indentLevel)."\n"; |
|
142 | + $result .= $this->addIndent('{', $indentLevel)."\n"; |
|
143 | 143 | |
144 | - if (!$this->source->isEmpty()) { |
|
145 | - $result .= $this->source->render($indentLevel + 1) . "\n"; |
|
144 | + if (!$this->source->isEmpty()){ |
|
145 | + $result .= $this->source->render($indentLevel + 1)."\n"; |
|
146 | 146 | } |
147 | 147 | |
148 | - return $result . $this->addIndent('}', $indentLevel); |
|
148 | + return $result.$this->addIndent('}', $indentLevel); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | private function renderModifiers(): string |
152 | 152 | { |
153 | 153 | $chunks = [$this->getAccess()]; |
154 | 154 | |
155 | - if ($this->isStatic()) { |
|
155 | + if ($this->isStatic()){ |
|
156 | 156 | $chunks[] = 'static'; |
157 | 157 | } |
158 | 158 | |
@@ -168,14 +168,14 @@ discard block |
||
168 | 168 | */ |
169 | 169 | private function initSource($source): void |
170 | 170 | { |
171 | - if (empty($this->source)) { |
|
171 | + if (empty($this->source)){ |
|
172 | 172 | $this->source = new Source(); |
173 | 173 | } |
174 | 174 | |
175 | - if (!empty($source)) { |
|
176 | - if (is_array($source)) { |
|
175 | + if (!empty($source)){ |
|
176 | + if (is_array($source)){ |
|
177 | 177 | $this->source->setLines($source); |
178 | - } elseif (is_string($source)) { |
|
178 | + } elseif (is_string($source)){ |
|
179 | 179 | $this->source->setString($source); |
180 | 180 | } |
181 | 181 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | public function __construct(string $name, $defaultValue = null, $comment = '') |
49 | 49 | { |
50 | 50 | $this->setName($name); |
51 | - if ($defaultValue !== null) { |
|
51 | + if ($defaultValue !== null){ |
|
52 | 52 | $this->setDefaultValue($defaultValue); |
53 | 53 | } |
54 | 54 | |
@@ -118,21 +118,21 @@ discard block |
||
118 | 118 | public function render(int $indentLevel = 0): string |
119 | 119 | { |
120 | 120 | $result = ''; |
121 | - if (!$this->docComment->isEmpty()) { |
|
122 | - $result .= $this->docComment->render($indentLevel) . "\n"; |
|
121 | + if (!$this->docComment->isEmpty()){ |
|
122 | + $result .= $this->docComment->render($indentLevel)."\n"; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | $result .= $this->addIndent("{$this->access} \${$this->getName()}", $indentLevel); |
126 | 126 | |
127 | - if ($this->hasDefault) { |
|
127 | + if ($this->hasDefault){ |
|
128 | 128 | $value = $this->getSerializer()->serialize($this->defaultValue); |
129 | 129 | |
130 | - if (is_array($this->defaultValue)) { |
|
130 | + if (is_array($this->defaultValue)){ |
|
131 | 131 | $value = $this->mountIndents($value, $indentLevel); |
132 | 132 | } |
133 | 133 | |
134 | 134 | $result .= " = {$value};"; |
135 | - } else { |
|
135 | + }else{ |
|
136 | 136 | $result .= ';'; |
137 | 137 | } |
138 | 138 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | private function mountIndents(string $serialized, int $indentLevel): string |
150 | 150 | { |
151 | 151 | $lines = explode("\n", $serialized); |
152 | - foreach ($lines as &$line) { |
|
152 | + foreach ($lines as &$line){ |
|
153 | 153 | $line = $this->addIndent($line, $indentLevel); |
154 | 154 | unset($line); |
155 | 155 | } |
@@ -48,7 +48,8 @@ discard block |
||
48 | 48 | public function __construct(string $name, $defaultValue = null, $comment = '') |
49 | 49 | { |
50 | 50 | $this->setName($name); |
51 | - if ($defaultValue !== null) { |
|
51 | + if ($defaultValue !== null) |
|
52 | + { |
|
52 | 53 | $this->setDefaultValue($defaultValue); |
53 | 54 | } |
54 | 55 | |
@@ -118,21 +119,26 @@ discard block |
||
118 | 119 | public function render(int $indentLevel = 0): string |
119 | 120 | { |
120 | 121 | $result = ''; |
121 | - if (!$this->docComment->isEmpty()) { |
|
122 | + if (!$this->docComment->isEmpty()) |
|
123 | + { |
|
122 | 124 | $result .= $this->docComment->render($indentLevel) . "\n"; |
123 | 125 | } |
124 | 126 | |
125 | 127 | $result .= $this->addIndent("{$this->access} \${$this->getName()}", $indentLevel); |
126 | 128 | |
127 | - if ($this->hasDefault) { |
|
129 | + if ($this->hasDefault) |
|
130 | + { |
|
128 | 131 | $value = $this->getSerializer()->serialize($this->defaultValue); |
129 | 132 | |
130 | - if (is_array($this->defaultValue)) { |
|
133 | + if (is_array($this->defaultValue)) |
|
134 | + { |
|
131 | 135 | $value = $this->mountIndents($value, $indentLevel); |
132 | 136 | } |
133 | 137 | |
134 | 138 | $result .= " = {$value};"; |
135 | - } else { |
|
139 | + } |
|
140 | + else |
|
141 | + { |
|
136 | 142 | $result .= ';'; |
137 | 143 | } |
138 | 144 | |
@@ -149,7 +155,8 @@ discard block |
||
149 | 155 | private function mountIndents(string $serialized, int $indentLevel): string |
150 | 156 | { |
151 | 157 | $lines = explode("\n", $serialized); |
152 | - foreach ($lines as &$line) { |
|
158 | + foreach ($lines as &$line) |
|
159 | + { |
|
153 | 160 | $line = $this->addIndent($line, $indentLevel); |
154 | 161 | unset($line); |
155 | 162 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function addLine(string $line): Source |
68 | 68 | { |
69 | - if (strpos($line, "\n") !== false) { |
|
69 | + if (strpos($line, "\n") !== false){ |
|
70 | 70 | throw new MultilineException( |
71 | 71 | 'New line character is forbidden in addLine method argument' |
72 | 72 | ); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public static function normalizeEndings(string $string, bool $joinMultiple = true): string |
134 | 134 | { |
135 | - if (!$joinMultiple) { |
|
135 | + if (!$joinMultiple){ |
|
136 | 136 | return str_replace("\r\n", "\n", $string); |
137 | 137 | } |
138 | 138 | |
@@ -164,30 +164,30 @@ discard block |
||
164 | 164 | $string = self::normalizeEndings($string, false); |
165 | 165 | $lines = explode("\n", $string); |
166 | 166 | $minIndent = null; |
167 | - foreach ($lines as $line) { |
|
168 | - if (!trim($line)) { |
|
167 | + foreach ($lines as $line){ |
|
168 | + if (!trim($line)){ |
|
169 | 169 | continue; |
170 | 170 | } |
171 | 171 | $line = str_replace("\t", $tabulationCost, $line); |
172 | 172 | //Getting indent size |
173 | - if (!preg_match('/^( +)/', $line, $matches)) { |
|
173 | + if (!preg_match('/^( +)/', $line, $matches)){ |
|
174 | 174 | //Some line has no indent |
175 | 175 | return $string; |
176 | 176 | } |
177 | - if ($minIndent === null) { |
|
177 | + if ($minIndent === null){ |
|
178 | 178 | $minIndent = strlen($matches[1]); |
179 | 179 | } |
180 | 180 | $minIndent = min($minIndent, strlen($matches[1])); |
181 | 181 | } |
182 | 182 | //Fixing indent |
183 | - foreach ($lines as &$line) { |
|
184 | - if (empty($line)) { |
|
183 | + foreach ($lines as &$line){ |
|
184 | + if (empty($line)){ |
|
185 | 185 | continue; |
186 | 186 | } |
187 | 187 | //Getting line indent |
188 | 188 | preg_match("/^([ \t]+)/", $line, $matches); |
189 | 189 | $indent = $matches[1]; |
190 | - if (!trim($line)) { |
|
190 | + if (!trim($line)){ |
|
191 | 191 | $line = ''; |
192 | 192 | continue; |
193 | 193 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | ' ', |
197 | 197 | strlen(str_replace("\t", $tabulationCost, $indent)) - $minIndent |
198 | 198 | ); |
199 | - $line = $useIndent . substr($line, strlen($indent)); |
|
199 | + $line = $useIndent.substr($line, strlen($indent)); |
|
200 | 200 | unset($line); |
201 | 201 | } |
202 | 202 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | protected function fetchLines(string $string, bool $cutIndents): array |
214 | 214 | { |
215 | - if ($cutIndents) { |
|
215 | + if ($cutIndents){ |
|
216 | 216 | $string = self::normalizeIndents($string, ''); |
217 | 217 | } |
218 | 218 |
@@ -66,7 +66,8 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function addLine(string $line): Source |
68 | 68 | { |
69 | - if (strpos($line, "\n") !== false) { |
|
69 | + if (strpos($line, "\n") !== false) |
|
70 | + { |
|
70 | 71 | throw new MultilineException( |
71 | 72 | 'New line character is forbidden in addLine method argument' |
72 | 73 | ); |
@@ -132,7 +133,8 @@ discard block |
||
132 | 133 | */ |
133 | 134 | public static function normalizeEndings(string $string, bool $joinMultiple = true): string |
134 | 135 | { |
135 | - if (!$joinMultiple) { |
|
136 | + if (!$joinMultiple) |
|
137 | + { |
|
136 | 138 | return str_replace("\r\n", "\n", $string); |
137 | 139 | } |
138 | 140 | |
@@ -164,30 +166,37 @@ discard block |
||
164 | 166 | $string = self::normalizeEndings($string, false); |
165 | 167 | $lines = explode("\n", $string); |
166 | 168 | $minIndent = null; |
167 | - foreach ($lines as $line) { |
|
168 | - if (!trim($line)) { |
|
169 | + foreach ($lines as $line) |
|
170 | + { |
|
171 | + if (!trim($line)) |
|
172 | + { |
|
169 | 173 | continue; |
170 | 174 | } |
171 | 175 | $line = str_replace("\t", $tabulationCost, $line); |
172 | 176 | //Getting indent size |
173 | - if (!preg_match('/^( +)/', $line, $matches)) { |
|
177 | + if (!preg_match('/^( +)/', $line, $matches)) |
|
178 | + { |
|
174 | 179 | //Some line has no indent |
175 | 180 | return $string; |
176 | 181 | } |
177 | - if ($minIndent === null) { |
|
182 | + if ($minIndent === null) |
|
183 | + { |
|
178 | 184 | $minIndent = strlen($matches[1]); |
179 | 185 | } |
180 | 186 | $minIndent = min($minIndent, strlen($matches[1])); |
181 | 187 | } |
182 | 188 | //Fixing indent |
183 | - foreach ($lines as &$line) { |
|
184 | - if (empty($line)) { |
|
189 | + foreach ($lines as &$line) |
|
190 | + { |
|
191 | + if (empty($line)) |
|
192 | + { |
|
185 | 193 | continue; |
186 | 194 | } |
187 | 195 | //Getting line indent |
188 | 196 | preg_match("/^([ \t]+)/", $line, $matches); |
189 | 197 | $indent = $matches[1]; |
190 | - if (!trim($line)) { |
|
198 | + if (!trim($line)) |
|
199 | + { |
|
191 | 200 | $line = ''; |
192 | 201 | continue; |
193 | 202 | } |
@@ -212,7 +221,8 @@ discard block |
||
212 | 221 | */ |
213 | 222 | protected function fetchLines(string $string, bool $cutIndents): array |
214 | 223 | { |
215 | - if ($cutIndents) { |
|
224 | + if ($cutIndents) |
|
225 | + { |
|
216 | 226 | $string = self::normalizeIndents($string, ''); |
217 | 227 | } |
218 | 228 |
@@ -38,7 +38,7 @@ |
||
38 | 38 | */ |
39 | 39 | public function get(string $name): Method |
40 | 40 | { |
41 | - if (!$this->has($name)) { |
|
41 | + if (!$this->has($name)){ |
|
42 | 42 | //Automatically creating constant |
43 | 43 | $method = new Method($name); |
44 | 44 | $this->add($method); |
@@ -38,7 +38,8 @@ |
||
38 | 38 | */ |
39 | 39 | public function get(string $name): Method |
40 | 40 | { |
41 | - if (!$this->has($name)) { |
|
41 | + if (!$this->has($name)) |
|
42 | + { |
|
42 | 43 | //Automatically creating constant |
43 | 44 | $method = new Method($name); |
44 | 45 | $this->add($method); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function get(string $name): Parameter |
40 | 40 | { |
41 | - if (!$this->has($name)) { |
|
41 | + if (!$this->has($name)){ |
|
42 | 42 | //Automatically creating constant |
43 | 43 | $parameter = new Parameter($name); |
44 | 44 | $this->add($parameter); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * Overwriting parent call. |
59 | 59 | */ |
60 | 60 | $parameters = []; |
61 | - foreach ($this->getIterator() as $element) { |
|
61 | + foreach ($this->getIterator() as $element){ |
|
62 | 62 | $parameters[] = $element->render(0); |
63 | 63 | } |
64 | 64 |
@@ -38,7 +38,8 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function get(string $name): Parameter |
40 | 40 | { |
41 | - if (!$this->has($name)) { |
|
41 | + if (!$this->has($name)) |
|
42 | + { |
|
42 | 43 | //Automatically creating constant |
43 | 44 | $parameter = new Parameter($name); |
44 | 45 | $this->add($parameter); |
@@ -58,7 +59,8 @@ discard block |
||
58 | 59 | * Overwriting parent call. |
59 | 60 | */ |
60 | 61 | $parameters = []; |
61 | - foreach ($this->getIterator() as $element) { |
|
62 | + foreach ($this->getIterator() as $element) |
|
63 | + { |
|
62 | 64 | $parameters[] = $element->render(0); |
63 | 65 | } |
64 | 66 |
@@ -38,7 +38,7 @@ |
||
38 | 38 | */ |
39 | 39 | public function get(string $name): Constant |
40 | 40 | { |
41 | - if (!$this->has($name)) { |
|
41 | + if (!$this->has($name)){ |
|
42 | 42 | $constant = new Constant($name, null); |
43 | 43 | $this->add($constant); |
44 | 44 |
@@ -38,7 +38,8 @@ |
||
38 | 38 | */ |
39 | 39 | public function get(string $name): Constant |
40 | 40 | { |
41 | - if (!$this->has($name)) { |
|
41 | + if (!$this->has($name)) |
|
42 | + { |
|
42 | 43 | $constant = new Constant($name, null); |
43 | 44 | $this->add($constant); |
44 | 45 |
@@ -38,7 +38,7 @@ |
||
38 | 38 | */ |
39 | 39 | public function get(string $name): Property |
40 | 40 | { |
41 | - if (!$this->has($name)) { |
|
41 | + if (!$this->has($name)){ |
|
42 | 42 | //Automatically creating constant |
43 | 43 | $property = new Property($name); |
44 | 44 | $this->add($property); |
@@ -38,7 +38,8 @@ |
||
38 | 38 | */ |
39 | 39 | public function get(string $name): Property |
40 | 40 | { |
41 | - if (!$this->has($name)) { |
|
41 | + if (!$this->has($name)) |
|
42 | + { |
|
42 | 43 | //Automatically creating constant |
43 | 44 | $property = new Property($name); |
44 | 45 | $this->add($property); |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function perform(DatabaseConfig $config, DatabaseManager $dbal): void |
36 | 36 | { |
37 | - if ($this->argument('db')) { |
|
37 | + if ($this->argument('db')){ |
|
38 | 38 | $databases = [$this->argument('db')]; |
39 | - } else { |
|
39 | + }else{ |
|
40 | 40 | $databases = array_keys($config->getDatabases()); |
41 | 41 | } |
42 | 42 | |
43 | - if (empty($databases)) { |
|
43 | + if (empty($databases)){ |
|
44 | 44 | $this->writeln('<fg=red>No databases found.</fg=red>'); |
45 | 45 | |
46 | 46 | return; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | ] |
59 | 59 | ); |
60 | 60 | |
61 | - foreach ($databases as $database) { |
|
61 | + foreach ($databases as $database){ |
|
62 | 62 | $database = $dbal->database($database); |
63 | 63 | |
64 | 64 | /** @var Driver $driver */ |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | $database->getPrefix() ?: '<comment>---</comment>', |
72 | 72 | ]; |
73 | 73 | |
74 | - try { |
|
74 | + try{ |
|
75 | 75 | $driver->connect(); |
76 | - } catch (\Exception $exception) { |
|
76 | + }catch (\Exception $exception){ |
|
77 | 77 | $this->renderException($grid, $header, $exception); |
78 | 78 | |
79 | - if ($database->getName() != end($databases)) { |
|
79 | + if ($database->getName() != end($databases)){ |
|
80 | 80 | $grid->addRow(new TableSeparator()); |
81 | 81 | } |
82 | 82 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | $header[] = '<info>connected</info>'; |
87 | 87 | $this->renderTables($grid, $header, $database); |
88 | - if ($database->getName() != end($databases)) { |
|
88 | + if ($database->getName() != end($databases)){ |
|
89 | 89 | $grid->addRow(new TableSeparator()); |
90 | 90 | } |
91 | 91 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | private function renderTables(Table $grid, array $header, Database $database): void |
121 | 121 | { |
122 | - foreach ($database->getTables() as $table) { |
|
122 | + foreach ($database->getTables() as $table){ |
|
123 | 123 | $grid->addRow( |
124 | 124 | array_merge( |
125 | 125 | $header, |
@@ -34,13 +34,17 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function perform(DatabaseConfig $config, DatabaseManager $dbal): void |
36 | 36 | { |
37 | - if ($this->argument('db')) { |
|
37 | + if ($this->argument('db')) |
|
38 | + { |
|
38 | 39 | $databases = [$this->argument('db')]; |
39 | - } else { |
|
40 | + } |
|
41 | + else |
|
42 | + { |
|
40 | 43 | $databases = array_keys($config->getDatabases()); |
41 | 44 | } |
42 | 45 | |
43 | - if (empty($databases)) { |
|
46 | + if (empty($databases)) |
|
47 | + { |
|
44 | 48 | $this->writeln('<fg=red>No databases found.</fg=red>'); |
45 | 49 | |
46 | 50 | return; |
@@ -58,7 +62,8 @@ discard block |
||
58 | 62 | ] |
59 | 63 | ); |
60 | 64 | |
61 | - foreach ($databases as $database) { |
|
65 | + foreach ($databases as $database) |
|
66 | + { |
|
62 | 67 | $database = $dbal->database($database); |
63 | 68 | |
64 | 69 | /** @var Driver $driver */ |
@@ -71,12 +76,16 @@ discard block |
||
71 | 76 | $database->getPrefix() ?: '<comment>---</comment>', |
72 | 77 | ]; |
73 | 78 | |
74 | - try { |
|
79 | + try |
|
80 | + { |
|
75 | 81 | $driver->connect(); |
76 | - } catch (\Exception $exception) { |
|
82 | + } |
|
83 | + catch (\Exception $exception) |
|
84 | + { |
|
77 | 85 | $this->renderException($grid, $header, $exception); |
78 | 86 | |
79 | - if ($database->getName() != end($databases)) { |
|
87 | + if ($database->getName() != end($databases)) |
|
88 | + { |
|
80 | 89 | $grid->addRow(new TableSeparator()); |
81 | 90 | } |
82 | 91 | |
@@ -85,7 +94,8 @@ discard block |
||
85 | 94 | |
86 | 95 | $header[] = '<info>connected</info>'; |
87 | 96 | $this->renderTables($grid, $header, $database); |
88 | - if ($database->getName() != end($databases)) { |
|
97 | + if ($database->getName() != end($databases)) |
|
98 | + { |
|
89 | 99 | $grid->addRow(new TableSeparator()); |
90 | 100 | } |
91 | 101 | } |
@@ -119,7 +129,8 @@ discard block |
||
119 | 129 | */ |
120 | 130 | private function renderTables(Table $grid, array $header, Database $database): void |
121 | 131 | { |
122 | - foreach ($database->getTables() as $table) { |
|
132 | + foreach ($database->getTables() as $table) |
|
133 | + { |
|
123 | 134 | $grid->addRow( |
124 | 135 | array_merge( |
125 | 136 | $header, |