Passed
Push — master ( 1dce98...7ec404 )
by Kirill
08:02
created
src/Framework/Bootloader/Distribution/DistributionConfig.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
      */
72 72
     private function bootResolvers(array $config): void
73 73
     {
74
-        foreach ($config['resolvers'] ?? [] as $name => $child) {
75
-            if (!\is_string($name)) {
74
+        foreach ($config['resolvers'] ?? [] as $name => $child){
75
+            if (!\is_string($name)){
76 76
                 throw new InvalidArgumentException(
77 77
                     \vsprintf('Distribution driver config key must be a string, but %s given', [
78 78
                         \get_debug_type($child),
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
                 );
81 81
             }
82 82
 
83
-            if (!\is_array($child)) {
83
+            if (!\is_array($child)){
84 84
                 throw new InvalidArgumentException(
85 85
                     \vsprintf('Distribution driver config `%s` must be an array, but %s given', [
86 86
                         $name,
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
     {
101 101
         $default = $config['default'] ?? null;
102 102
 
103
-        if ($default !== null) {
103
+        if ($default !== null){
104 104
             // Validate config
105
-            if (!\is_string($default)) {
105
+            if (!\is_string($default)){
106 106
                 throw new InvalidArgumentException(
107 107
                     \vsprintf('Distribution config default driver must be a string, but %s given', [
108 108
                         \get_debug_type($default),
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
      */
122 122
     private function createResolver(string $name, array $config): UriResolverInterface
123 123
     {
124
-        if (!isset($config['type']) || !\is_string($config['type'])) {
124
+        if (!isset($config['type']) || !\is_string($config['type'])){
125 125
             throw $this->invalidConfigKey($name, 'type', 'string');
126 126
         }
127 127
 
128 128
         $type = $config['type'];
129 129
 
130
-        switch ($type) {
130
+        switch ($type){
131 131
             case 'static':
132 132
                 return $this->createStaticResolver($name, $config);
133 133
 
@@ -150,17 +150,17 @@  discard block
 block discarded – undo
150 150
      */
151 151
     private function createCustomResolver(string $type, string $name, array $config): UriResolverInterface
152 152
     {
153
-        if (!\is_subclass_of($type, UriResolverInterface::class, true)) {
153
+        if (!\is_subclass_of($type, UriResolverInterface::class, true)){
154 154
             throw $this->invalidConfigKey($name, 'type', UriResolverInterface::class);
155 155
         }
156 156
 
157
-        if (isset($config['options']) && !\is_array($config['options'])) {
157
+        if (isset($config['options']) && !\is_array($config['options'])){
158 158
             throw $this->invalidConfigKey($name, 'options', 'array');
159 159
         }
160 160
 
161
-        try {
161
+        try{
162 162
             return new $type(...\array_values($config['options'] ?? []));
163
-        } catch (\Throwable $e) {
163
+        }catch (\Throwable $e){
164 164
             $message = 'An error occurred while resolver `%s` initializing: %s';
165 165
             throw new InvalidArgumentException(\sprintf($message, $name, $e->getMessage()), 0, $e);
166 166
         }
@@ -174,32 +174,32 @@  discard block
 block discarded – undo
174 174
     private function createS3Resolver(string $name, array $config): UriResolverInterface
175 175
     {
176 176
         // Required config options
177
-        if (!isset($config['region']) || !\is_string($config['region'])) {
177
+        if (!isset($config['region']) || !\is_string($config['region'])){
178 178
             throw $this->invalidConfigKey($name, 'region', 'string');
179 179
         }
180 180
 
181
-        if (!isset($config['key']) || !\is_string($config['key'])) {
181
+        if (!isset($config['key']) || !\is_string($config['key'])){
182 182
             throw $this->invalidConfigKey($name, 'key', 'string');
183 183
         }
184 184
 
185
-        if (!isset($config['secret']) || !\is_string($config['secret'])) {
185
+        if (!isset($config['secret']) || !\is_string($config['secret'])){
186 186
             throw $this->invalidConfigKey($name, 'secret', 'string');
187 187
         }
188 188
 
189
-        if (!isset($config['bucket']) || !\is_string($config['bucket'])) {
189
+        if (!isset($config['bucket']) || !\is_string($config['bucket'])){
190 190
             throw $this->invalidConfigKey($name, 'bucket', 'string');
191 191
         }
192 192
 
193 193
         // Optional config options
194
-        if (!\is_string($config['version'] ?? '')) {
194
+        if (!\is_string($config['version'] ?? '')){
195 195
             throw $this->invalidConfigKey($name, 'version', 'string or null');
196 196
         }
197 197
 
198
-        if (!\is_string($config['token'] ?? '')) {
198
+        if (!\is_string($config['token'] ?? '')){
199 199
             throw $this->invalidConfigKey($name, 'token', 'string or null');
200 200
         }
201 201
 
202
-        if (!\is_int($config['expires'] ?? 0)) {
202
+        if (!\is_int($config['expires'] ?? 0)){
203 203
             throw $this->invalidConfigKey($name, 'expires', 'positive int (unix timestamp)');
204 204
         }
205 205
 
@@ -224,15 +224,15 @@  discard block
 block discarded – undo
224 224
      */
225 225
     private function createCloudFrontResolver(string $name, array $config): UriResolverInterface
226 226
     {
227
-        if (!isset($config['key']) || !\is_string($config['key'])) {
227
+        if (!isset($config['key']) || !\is_string($config['key'])){
228 228
             throw $this->invalidConfigKey($name, 'key', 'string');
229 229
         }
230 230
 
231
-        if (!isset($config['private']) || !\is_string($config['private'])) {
231
+        if (!isset($config['private']) || !\is_string($config['private'])){
232 232
             throw $this->invalidConfigKey($name, 'private', 'string value or path to key file');
233 233
         }
234 234
 
235
-        if (!isset($config['domain']) || !\is_string($config['domain'])) {
235
+        if (!isset($config['domain']) || !\is_string($config['domain'])){
236 236
             throw $this->invalidConfigKey($name, 'domain', 'string');
237 237
         }
238 238
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
      */
251 251
     private function createStaticResolver(string $name, array $config): UriResolverInterface
252 252
     {
253
-        if (!isset($config['uri']) || !\is_string($config['uri'])) {
253
+        if (!isset($config['uri']) || !\is_string($config['uri'])){
254 254
             throw $this->invalidConfigKey($name, 'uri', 'string');
255 255
         }
256 256
 
@@ -265,17 +265,17 @@  discard block
 block discarded – undo
265 265
      */
266 266
     private function createUri(string $name, string $uri, array $config): UriInterface
267 267
     {
268
-        if (!\is_string($config['factory'] ?? '')) {
268
+        if (!\is_string($config['factory'] ?? '')){
269 269
             throw $this->invalidConfigKey($name, 'factory', 'string (PSR-7 uri factory implementation)');
270 270
         }
271 271
 
272
-        switch (true) {
272
+        switch (true){
273 273
             case isset($config['factory']):
274 274
                 /** @var UriFactoryInterface $factory */
275 275
                 $factory = new $config['factory']();
276 276
 
277
-                if (!$factory instanceof UriFactoryInterface) {
278
-                    $message = 'Distribution config driver `%s` should contain class that must be a valid PSR-7 ' .
277
+                if (!$factory instanceof UriFactoryInterface){
278
+                    $message = 'Distribution config driver `%s` should contain class that must be a valid PSR-7 '.
279 279
                         'uri factory implementation, but `%s` given';
280 280
                     throw new InvalidArgumentException(\sprintf($message, $name, $config['factory']));
281 281
                 }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
                 return new GuzzleUri($uri);
290 290
 
291 291
             default:
292
-                $message = 'Can not resolve available PSR-7 UriFactory implementation; ' .
292
+                $message = 'Can not resolve available PSR-7 UriFactory implementation; '.
293 293
                     'Please define `factory` config section in `%s` distribution driver config';
294 294
                 throw new InvalidArgumentException(\sprintf($message, $name));
295 295
         }
Please login to merge, or discard this patch.
src/Distribution/src/Resolver/StaticResolver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,6 +75,6 @@
 block discarded – undo
75 75
         $prefix = \trim($this->host->getPath(), self::URI_PATH_DELIMITER);
76 76
         $file = \trim($file, self::URI_PATH_DELIMITER);
77 77
 
78
-        return self::URI_PATH_DELIMITER . ('' === $prefix ? '' : $prefix . self::URI_PATH_DELIMITER) . $file;
78
+        return self::URI_PATH_DELIMITER.('' === $prefix ? '' : $prefix.self::URI_PATH_DELIMITER).$file;
79 79
     }
80 80
 }
Please login to merge, or discard this patch.
src/Framework/Command/Cycle/Generator/ShowChanges.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
         $this->output->writeln('<info>Detecting schema changes:</info>');
43 43
 
44 44
         $this->changes = [];
45
-        foreach ($registry->getIterator() as $e) {
46
-            if ($registry->hasTable($e)) {
45
+        foreach ($registry->getIterator() as $e){
46
+            if ($registry->hasTable($e)){
47 47
                 $table = $registry->getTableSchema($e);
48 48
 
49
-                if ($table->getComparator()->hasChanges()) {
50
-                    $key = $registry->getDatabase($e) . ':' . $registry->getTable($e);
49
+                if ($table->getComparator()->hasChanges()){
50
+                    $key = $registry->getDatabase($e).':'.$registry->getTable($e);
51 51
                     $this->changes[$key] = [
52 52
                         'database' => $registry->getDatabase($e),
53 53
                         'table'    => $registry->getTable($e),
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
             }
58 58
         }
59 59
 
60
-        if ($this->changes === []) {
60
+        if ($this->changes === []){
61 61
             $this->output->writeln('<fg=yellow>no database changes has been detected</fg=yellow>');
62 62
 
63 63
             return $registry;
64 64
         }
65 65
 
66
-        foreach ($this->changes as $change) {
66
+        foreach ($this->changes as $change){
67 67
             $this->output->write(sprintf('• <fg=cyan>%s.%s</fg=cyan>', $change['database'], $change['table']));
68 68
             $this->describeChanges($change['schema']);
69 69
         }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     protected function describeChanges(AbstractTable $table): void
86 86
     {
87
-        if (!$this->output->isVerbose()) {
87
+        if (!$this->output->isVerbose()){
88 88
             $this->output->writeln(
89 89
                 sprintf(
90 90
                     ': <fg=green>%s</fg=green> change(s) detected',
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
         $this->output->write("\n");
98 98
 
99 99
 
100
-        if (!$table->exists()) {
100
+        if (!$table->exists()){
101 101
             $this->output->writeln('    - create table');
102 102
         }
103 103
 
104
-        if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) {
104
+        if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED){
105 105
             $this->output->writeln('    - drop table');
106 106
             return;
107 107
         }
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
      */
119 119
     protected function describeColumns(Comparator $cmp): void
120 120
     {
121
-        foreach ($cmp->addedColumns() as $column) {
121
+        foreach ($cmp->addedColumns() as $column){
122 122
             $this->output->writeln("    - add column <fg=yellow>{$column->getName()}</fg=yellow>");
123 123
         }
124 124
 
125
-        foreach ($cmp->droppedColumns() as $column) {
125
+        foreach ($cmp->droppedColumns() as $column){
126 126
             $this->output->writeln("    - drop column <fg=yellow>{$column->getName()}</fg=yellow>");
127 127
         }
128 128
 
129
-        foreach ($cmp->alteredColumns() as $column) {
129
+        foreach ($cmp->alteredColumns() as $column){
130 130
             $column = $column[0];
131 131
             $this->output->writeln("    - alter column <fg=yellow>{$column->getName()}</fg=yellow>");
132 132
         }
@@ -137,17 +137,17 @@  discard block
 block discarded – undo
137 137
      */
138 138
     protected function describeIndexes(Comparator $cmp): void
139 139
     {
140
-        foreach ($cmp->addedIndexes() as $index) {
140
+        foreach ($cmp->addedIndexes() as $index){
141 141
             $index = implode(', ', $index->getColumns());
142 142
             $this->output->writeln("    - add index on <fg=yellow>[{$index}]</fg=yellow>");
143 143
         }
144 144
 
145
-        foreach ($cmp->droppedIndexes() as $index) {
145
+        foreach ($cmp->droppedIndexes() as $index){
146 146
             $index = implode(', ', $index->getColumns());
147 147
             $this->output->writeln("    - drop index on <fg=yellow>[{$index}]</fg=yellow>");
148 148
         }
149 149
 
150
-        foreach ($cmp->alteredIndexes() as $index) {
150
+        foreach ($cmp->alteredIndexes() as $index){
151 151
             $index = $index[0];
152 152
             $index = implode(', ', $index->getColumns());
153 153
             $this->output->writeln("    - alter index on <fg=yellow>[{$index}]</fg=yellow>");
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
      */
160 160
     protected function describeFKs(Comparator $cmp): void
161 161
     {
162
-        foreach ($cmp->addedForeignKeys() as $fk) {
162
+        foreach ($cmp->addedForeignKeys() as $fk){
163 163
             $fkColumns = implode(', ', $fk->getColumns());
164 164
             $this->output->writeln("    - add foreign key on <fg=yellow>{$fkColumns}</fg=yellow>");
165 165
         }
166 166
 
167
-        foreach ($cmp->droppedForeignKeys() as $fk) {
167
+        foreach ($cmp->droppedForeignKeys() as $fk){
168 168
             $fkColumns = implode(', ', $fk->getColumns());
169 169
             $this->output->writeln("    - drop foreign key <fg=yellow>{$fkColumns}</fg=yellow>");
170 170
         }
171 171
 
172
-        foreach ($cmp->alteredForeignKeys() as $fk) {
172
+        foreach ($cmp->alteredForeignKeys() as $fk){
173 173
             $fk = $fk[0];
174 174
             $fkColumns = implode(', ', $fk->getColumns());
175 175
             $this->output->writeln("    - alter foreign key <fg=yellow>{$fkColumns}</fg=yellow>");
Please login to merge, or discard this patch.
Braces   +34 added lines, -17 removed lines patch added patch discarded remove patch
@@ -42,11 +42,14 @@  discard block
 block discarded – undo
42 42
         $this->output->writeln('<info>Detecting schema changes:</info>');
43 43
 
44 44
         $this->changes = [];
45
-        foreach ($registry->getIterator() as $e) {
46
-            if ($registry->hasTable($e)) {
45
+        foreach ($registry->getIterator() as $e)
46
+        {
47
+            if ($registry->hasTable($e))
48
+            {
47 49
                 $table = $registry->getTableSchema($e);
48 50
 
49
-                if ($table->getComparator()->hasChanges()) {
51
+                if ($table->getComparator()->hasChanges())
52
+                {
50 53
                     $key = $registry->getDatabase($e) . ':' . $registry->getTable($e);
51 54
                     $this->changes[$key] = [
52 55
                         'database' => $registry->getDatabase($e),
@@ -57,13 +60,15 @@  discard block
 block discarded – undo
57 60
             }
58 61
         }
59 62
 
60
-        if ($this->changes === []) {
63
+        if ($this->changes === [])
64
+        {
61 65
             $this->output->writeln('<fg=yellow>no database changes has been detected</fg=yellow>');
62 66
 
63 67
             return $registry;
64 68
         }
65 69
 
66
-        foreach ($this->changes as $change) {
70
+        foreach ($this->changes as $change)
71
+        {
67 72
             $this->output->write(sprintf('• <fg=cyan>%s.%s</fg=cyan>', $change['database'], $change['table']));
68 73
             $this->describeChanges($change['schema']);
69 74
         }
@@ -84,7 +89,8 @@  discard block
 block discarded – undo
84 89
      */
85 90
     protected function describeChanges(AbstractTable $table): void
86 91
     {
87
-        if (!$this->output->isVerbose()) {
92
+        if (!$this->output->isVerbose())
93
+        {
88 94
             $this->output->writeln(
89 95
                 sprintf(
90 96
                     ': <fg=green>%s</fg=green> change(s) detected',
@@ -97,11 +103,13 @@  discard block
 block discarded – undo
97 103
         $this->output->write("\n");
98 104
 
99 105
 
100
-        if (!$table->exists()) {
106
+        if (!$table->exists())
107
+        {
101 108
             $this->output->writeln('    - create table');
102 109
         }
103 110
 
104
-        if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) {
111
+        if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED)
112
+        {
105 113
             $this->output->writeln('    - drop table');
106 114
             return;
107 115
         }
@@ -118,15 +126,18 @@  discard block
 block discarded – undo
118 126
      */
119 127
     protected function describeColumns(Comparator $cmp): void
120 128
     {
121
-        foreach ($cmp->addedColumns() as $column) {
129
+        foreach ($cmp->addedColumns() as $column)
130
+        {
122 131
             $this->output->writeln("    - add column <fg=yellow>{$column->getName()}</fg=yellow>");
123 132
         }
124 133
 
125
-        foreach ($cmp->droppedColumns() as $column) {
134
+        foreach ($cmp->droppedColumns() as $column)
135
+        {
126 136
             $this->output->writeln("    - drop column <fg=yellow>{$column->getName()}</fg=yellow>");
127 137
         }
128 138
 
129
-        foreach ($cmp->alteredColumns() as $column) {
139
+        foreach ($cmp->alteredColumns() as $column)
140
+        {
130 141
             $column = $column[0];
131 142
             $this->output->writeln("    - alter column <fg=yellow>{$column->getName()}</fg=yellow>");
132 143
         }
@@ -137,17 +148,20 @@  discard block
 block discarded – undo
137 148
      */
138 149
     protected function describeIndexes(Comparator $cmp): void
139 150
     {
140
-        foreach ($cmp->addedIndexes() as $index) {
151
+        foreach ($cmp->addedIndexes() as $index)
152
+        {
141 153
             $index = implode(', ', $index->getColumns());
142 154
             $this->output->writeln("    - add index on <fg=yellow>[{$index}]</fg=yellow>");
143 155
         }
144 156
 
145
-        foreach ($cmp->droppedIndexes() as $index) {
157
+        foreach ($cmp->droppedIndexes() as $index)
158
+        {
146 159
             $index = implode(', ', $index->getColumns());
147 160
             $this->output->writeln("    - drop index on <fg=yellow>[{$index}]</fg=yellow>");
148 161
         }
149 162
 
150
-        foreach ($cmp->alteredIndexes() as $index) {
163
+        foreach ($cmp->alteredIndexes() as $index)
164
+        {
151 165
             $index = $index[0];
152 166
             $index = implode(', ', $index->getColumns());
153 167
             $this->output->writeln("    - alter index on <fg=yellow>[{$index}]</fg=yellow>");
@@ -159,17 +173,20 @@  discard block
 block discarded – undo
159 173
      */
160 174
     protected function describeFKs(Comparator $cmp): void
161 175
     {
162
-        foreach ($cmp->addedForeignKeys() as $fk) {
176
+        foreach ($cmp->addedForeignKeys() as $fk)
177
+        {
163 178
             $fkColumns = implode(', ', $fk->getColumns());
164 179
             $this->output->writeln("    - add foreign key on <fg=yellow>{$fkColumns}</fg=yellow>");
165 180
         }
166 181
 
167
-        foreach ($cmp->droppedForeignKeys() as $fk) {
182
+        foreach ($cmp->droppedForeignKeys() as $fk)
183
+        {
168 184
             $fkColumns = implode(', ', $fk->getColumns());
169 185
             $this->output->writeln("    - drop foreign key <fg=yellow>{$fkColumns}</fg=yellow>");
170 186
         }
171 187
 
172
-        foreach ($cmp->alteredForeignKeys() as $fk) {
188
+        foreach ($cmp->alteredForeignKeys() as $fk)
189
+        {
173 190
             $fk = $fk[0];
174 191
             $fkColumns = implode(', ', $fk->getColumns());
175 192
             $this->output->writeln("    - alter foreign key <fg=yellow>{$fkColumns}</fg=yellow>");
Please login to merge, or discard this patch.