Passed
Branch 2.0 (27b8db)
by Anton
05:03
created
src/Command/Cycle/Generator/ShowChanges.php 1 patch
Braces   +37 added lines, -18 removed lines patch added patch discarded remove patch
@@ -40,11 +40,14 @@  discard block
 block discarded – undo
40 40
         $this->output->writeln("<info>Detecting schema changes:</info>");
41 41
 
42 42
         $this->changes = [];
43
-        foreach ($registry->getIterator() as $e) {
44
-            if ($registry->hasTable($e)) {
43
+        foreach ($registry->getIterator() as $e)
44
+        {
45
+            if ($registry->hasTable($e))
46
+            {
45 47
                 $table = $registry->getTableSchema($e);
46 48
 
47
-                if ($table->getComparator()->hasChanges()) {
49
+                if ($table->getComparator()->hasChanges())
50
+                {
48 51
                     $this->changes[] = [
49 52
                         'database' => $registry->getDatabase($e),
50 53
                         'table'    => $registry->getTable($e),
@@ -54,13 +57,15 @@  discard block
 block discarded – undo
54 57
             }
55 58
         }
56 59
 
57
-        if ($this->changes === []) {
60
+        if ($this->changes === [])
61
+        {
58 62
             $this->output->writeln("<fg=yellow>no database changes has been detected</fg=yellow>");
59 63
 
60 64
             return $registry;
61 65
         }
62 66
 
63
-        foreach ($this->changes as $change) {
67
+        foreach ($this->changes as $change)
68
+        {
64 69
             $this->output->write(sprintf("• <fg=cyan>%s.%s</fg=cyan>", $change['database'], $change['table']));
65 70
             $this->describeChanges($change['schema']);
66 71
         }
@@ -73,22 +78,27 @@  discard block
 block discarded – undo
73 78
      */
74 79
     protected function describeChanges(AbstractTable $table)
75 80
     {
76
-        if (!$this->output->isVerbose()) {
81
+        if (!$this->output->isVerbose())
82
+        {
77 83
             $this->output->writeln(sprintf(
78 84
                 ": <fg=green>%s</fg=green> change(s) detected",
79 85
                 $this->numChanges($table)
80 86
             ));
81 87
 
82 88
             return;
83
-        } else {
89
+        }
90
+        else
91
+        {
84 92
             $this->output->write("\n");
85 93
         }
86 94
 
87
-        if (!$table->exists()) {
95
+        if (!$table->exists())
96
+        {
88 97
             $this->output->writeln("    - create table");
89 98
         }
90 99
 
91
-        if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) {
100
+        if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED)
101
+        {
92 102
             $this->output->writeln("    - drop table");
93 103
             return;
94 104
         }
@@ -105,15 +115,18 @@  discard block
 block discarded – undo
105 115
      */
106 116
     protected function describeColumns(Comparator $cmp)
107 117
     {
108
-        foreach ($cmp->addedColumns() as $column) {
118
+        foreach ($cmp->addedColumns() as $column)
119
+        {
109 120
             $this->output->writeln("    - add column <fg=yellow>{$column->getName()}</fg=yellow>");
110 121
         }
111 122
 
112
-        foreach ($cmp->droppedColumns() as $column) {
123
+        foreach ($cmp->droppedColumns() as $column)
124
+        {
113 125
             $this->output->writeln("    - drop column <fg=yellow>{$column->getName()}</fg=yellow>");
114 126
         }
115 127
 
116
-        foreach ($cmp->alteredColumns() as $column) {
128
+        foreach ($cmp->alteredColumns() as $column)
129
+        {
117 130
             $column = $column[0];
118 131
             $this->output->writeln("    - alter column <fg=yellow>{$column->getName()}</fg=yellow>");
119 132
         }
@@ -124,16 +137,19 @@  discard block
 block discarded – undo
124 137
      */
125 138
     protected function describeIndexes(Comparator $cmp)
126 139
     {
127
-        foreach ($cmp->addedIndexes() as $index) {
140
+        foreach ($cmp->addedIndexes() as $index)
141
+        {
128 142
             $index = join(', ', $index->getColumns());
129 143
             $this->output->writeln("    - add index on <fg=yellow>[{$index}]</fg=yellow>");
130 144
         }
131 145
 
132
-        foreach ($cmp->droppedIndexes() as $index) {
146
+        foreach ($cmp->droppedIndexes() as $index)
147
+        {
133 148
             $this->output->writeln("    - drop index on <fg=yellow>[{$index}]</fg=yellow>");
134 149
         }
135 150
 
136
-        foreach ($cmp->alteredIndexes() as $index) {
151
+        foreach ($cmp->alteredIndexes() as $index)
152
+        {
137 153
             $index = $index[0];
138 154
             $this->output->writeln("    - alter index on <fg=yellow>[{$index}]</fg=yellow>");
139 155
         }
@@ -144,15 +160,18 @@  discard block
 block discarded – undo
144 160
      */
145 161
     protected function describeFKs(Comparator $cmp)
146 162
     {
147
-        foreach ($cmp->addedForeignKeys() as $fk) {
163
+        foreach ($cmp->addedForeignKeys() as $fk)
164
+        {
148 165
             $this->output->writeln("    - add foreign key on <fg=yellow>{$fk->getColumn()}</fg=yellow>");
149 166
         }
150 167
 
151
-        foreach ($cmp->droppedForeignKeys() as $fk) {
168
+        foreach ($cmp->droppedForeignKeys() as $fk)
169
+        {
152 170
             $this->output->writeln("    - drop foreign key <fg=yellow>{$fk->getColumn()}</fg=yellow>");
153 171
         }
154 172
 
155
-        foreach ($cmp->alteredForeignKeys() as $fk) {
173
+        foreach ($cmp->alteredForeignKeys() as $fk)
174
+        {
156 175
             $fk = $fk[0];
157 176
             $this->output->writeln("    - alter foreign key <fg=yellow>{$fk->getColumn()}</fg=yellow>");
158 177
         }
Please login to merge, or discard this patch.