Passed
Branch 2.0 (27b8db)
by Anton
05:03
created
src/Command/Cycle/Generator/ShowChanges.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  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
+            if ($registry->hasTable($e)){
45 45
                 $table = $registry->getTableSchema($e);
46 46
 
47
-                if ($table->getComparator()->hasChanges()) {
47
+                if ($table->getComparator()->hasChanges()){
48 48
                     $this->changes[] = [
49 49
                         'database' => $registry->getDatabase($e),
50 50
                         'table'    => $registry->getTable($e),
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
             }
55 55
         }
56 56
 
57
-        if ($this->changes === []) {
57
+        if ($this->changes === []){
58 58
             $this->output->writeln("<fg=yellow>no database changes has been detected</fg=yellow>");
59 59
 
60 60
             return $registry;
61 61
         }
62 62
 
63
-        foreach ($this->changes as $change) {
63
+        foreach ($this->changes as $change){
64 64
             $this->output->write(sprintf("• <fg=cyan>%s.%s</fg=cyan>", $change['database'], $change['table']));
65 65
             $this->describeChanges($change['schema']);
66 66
         }
@@ -73,22 +73,22 @@  discard block
 block discarded – undo
73 73
      */
74 74
     protected function describeChanges(AbstractTable $table)
75 75
     {
76
-        if (!$this->output->isVerbose()) {
76
+        if (!$this->output->isVerbose()){
77 77
             $this->output->writeln(sprintf(
78 78
                 ": <fg=green>%s</fg=green> change(s) detected",
79 79
                 $this->numChanges($table)
80 80
             ));
81 81
 
82 82
             return;
83
-        } else {
83
+        }else{
84 84
             $this->output->write("\n");
85 85
         }
86 86
 
87
-        if (!$table->exists()) {
87
+        if (!$table->exists()){
88 88
             $this->output->writeln("    - create table");
89 89
         }
90 90
 
91
-        if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) {
91
+        if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED){
92 92
             $this->output->writeln("    - drop table");
93 93
             return;
94 94
         }
@@ -105,15 +105,15 @@  discard block
 block discarded – undo
105 105
      */
106 106
     protected function describeColumns(Comparator $cmp)
107 107
     {
108
-        foreach ($cmp->addedColumns() as $column) {
108
+        foreach ($cmp->addedColumns() as $column){
109 109
             $this->output->writeln("    - add column <fg=yellow>{$column->getName()}</fg=yellow>");
110 110
         }
111 111
 
112
-        foreach ($cmp->droppedColumns() as $column) {
112
+        foreach ($cmp->droppedColumns() as $column){
113 113
             $this->output->writeln("    - drop column <fg=yellow>{$column->getName()}</fg=yellow>");
114 114
         }
115 115
 
116
-        foreach ($cmp->alteredColumns() as $column) {
116
+        foreach ($cmp->alteredColumns() as $column){
117 117
             $column = $column[0];
118 118
             $this->output->writeln("    - alter column <fg=yellow>{$column->getName()}</fg=yellow>");
119 119
         }
@@ -124,16 +124,16 @@  discard block
 block discarded – undo
124 124
      */
125 125
     protected function describeIndexes(Comparator $cmp)
126 126
     {
127
-        foreach ($cmp->addedIndexes() as $index) {
127
+        foreach ($cmp->addedIndexes() as $index){
128 128
             $index = join(', ', $index->getColumns());
129 129
             $this->output->writeln("    - add index on <fg=yellow>[{$index}]</fg=yellow>");
130 130
         }
131 131
 
132
-        foreach ($cmp->droppedIndexes() as $index) {
132
+        foreach ($cmp->droppedIndexes() as $index){
133 133
             $this->output->writeln("    - drop index on <fg=yellow>[{$index}]</fg=yellow>");
134 134
         }
135 135
 
136
-        foreach ($cmp->alteredIndexes() as $index) {
136
+        foreach ($cmp->alteredIndexes() as $index){
137 137
             $index = $index[0];
138 138
             $this->output->writeln("    - alter index on <fg=yellow>[{$index}]</fg=yellow>");
139 139
         }
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
      */
145 145
     protected function describeFKs(Comparator $cmp)
146 146
     {
147
-        foreach ($cmp->addedForeignKeys() as $fk) {
147
+        foreach ($cmp->addedForeignKeys() as $fk){
148 148
             $this->output->writeln("    - add foreign key on <fg=yellow>{$fk->getColumn()}</fg=yellow>");
149 149
         }
150 150
 
151
-        foreach ($cmp->droppedForeignKeys() as $fk) {
151
+        foreach ($cmp->droppedForeignKeys() as $fk){
152 152
             $this->output->writeln("    - drop foreign key <fg=yellow>{$fk->getColumn()}</fg=yellow>");
153 153
         }
154 154
 
155
-        foreach ($cmp->alteredForeignKeys() as $fk) {
155
+        foreach ($cmp->alteredForeignKeys() as $fk){
156 156
             $fk = $fk[0];
157 157
             $this->output->writeln("    - alter foreign key <fg=yellow>{$fk->getColumn()}</fg=yellow>");
158 158
         }
Please login to merge, or discard this 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.