Completed
Push — master ( 8e3086...7f1dfb )
by Joao
20s
created
src/Database/AbstractDatabase.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,15 +63,15 @@  discard block
 block discarded – undo
63 63
      */
64 64
     public function getVersion()
65 65
     {
66
-        $result = [];
66
+        $result = [ ];
67 67
         try {
68
-            $result['version'] = $this->getDbDriver()->getScalar('SELECT version FROM ' . $this->getMigrationTable());
68
+            $result[ 'version' ] = $this->getDbDriver()->getScalar('SELECT version FROM ' . $this->getMigrationTable());
69 69
         } catch (\Exception $ex) {
70 70
             throw new DatabaseNotVersionedException('This database does not have a migration version. Please use "migrate reset" or "migrate install" to create one.');
71 71
         }
72 72
 
73 73
         try {
74
-            $result['status'] = $this->getDbDriver()->getScalar('SELECT status FROM ' . $this->getMigrationTable());
74
+            $result[ 'status' ] = $this->getDbDriver()->getScalar('SELECT status FROM ' . $this->getMigrationTable());
75 75
         } catch (\Exception $ex) {
76 76
             throw new OldVersionSchemaException('This database does not have a migration version. Please use "migrate install" for update it.');
77 77
         }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     {
103 103
         // Get the version to check if exists
104 104
         $versionInfo = $this->getVersion();
105
-        if ($versionInfo['version'] === false) {
105
+        if ($versionInfo[ 'version' ] === false) {
106 106
             $this->getDbDriver()->execute(sprintf(
107 107
                 "insert into %s values(0, '%s')",
108 108
                 $this->getMigrationTable(),
Please login to merge, or discard this patch.
src/Migration.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     /**
44 44
      * @var array
45 45
      */
46
-    protected $databases = [];
46
+    protected $databases = [ ];
47 47
     /**
48 48
      * @var string
49 49
      */
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      */
76 76
     public function registerDatabase($scheme, $className)
77 77
     {
78
-        $this->databases[$scheme] = $className;
78
+        $this->databases[ $scheme ] = $className;
79 79
         return $this;
80 80
     }
81 81
 
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
      */
108 108
     protected function getDatabaseClassName()
109 109
     {
110
-        if (isset($this->databases[$this->uri->getScheme()])) {
111
-            return $this->databases[$this->uri->getScheme()];
110
+        if (isset($this->databases[ $this->uri->getScheme() ])) {
111
+            return $this->databases[ $this->uri->getScheme() ];
112 112
         }
113 113
         throw new DatabaseDoesNotRegistered(
114 114
             'Scheme "' . $this->uri->getScheme() . '" does not found. Did you registered it?'
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             . "/" . ($increment < 0 ? "down" : "up")
149 149
             . "/*.sql";
150 150
 
151
-        $result = array_filter(glob($filePattern), function ($file) use ($version) {
151
+        $result = array_filter(glob($filePattern), function($file) use ($version) {
152 152
             return preg_match("/^0*$version(-dev)?\.sql$/", basename($file));
153 153
         });
154 154
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
     public function reset($upVersion = null)
191 191
     {
192 192
         if ($this->callableProgress) {
193
-            call_user_func_array($this->callableProgress, ['reset', 0]);
193
+            call_user_func_array($this->callableProgress, [ 'reset', 0 ]);
194 194
         }
195 195
         $this->getDbCommand()->dropDatabase();
196 196
         $this->getDbCommand()->createDatabase();
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
     protected function migrate($upVersion, $increment, $force)
266 266
     {
267 267
         $versionInfo = $this->getCurrentVersion();
268
-        $currentVersion = intval($versionInfo['version']) + $increment;
268
+        $currentVersion = intval($versionInfo[ 'version' ]) + $increment;
269 269
 
270
-        if (strpos($versionInfo['status'], Migration::VERSION_STATUS_PARTIAL) !== false && !$force) {
270
+        if (strpos($versionInfo[ 'status' ], Migration::VERSION_STATUS_PARTIAL) !== false && !$force) {
271 271
             throw new DatabaseIsIncompleteException('Database was not fully updated. Use --force for migrate.');
272 272
         }
273 273
 
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
             && file_exists($file = $this->getMigrationSql($currentVersion, $increment))
276 276
         ) {
277 277
             if ($this->callableProgress) {
278
-                call_user_func_array($this->callableProgress, ['migrate', $currentVersion]);
278
+                call_user_func_array($this->callableProgress, [ 'migrate', $currentVersion ]);
279 279
             }
280 280
 
281
-            $this->getDbCommand()->setVersion($currentVersion, Migration::VERSION_STATUS_PARTIAL . ' ' . ($increment>0 ? 'up' : 'down'));
281
+            $this->getDbCommand()->setVersion($currentVersion, Migration::VERSION_STATUS_PARTIAL . ' ' . ($increment > 0 ? 'up' : 'down'));
282 282
             $this->getDbCommand()->executeSql(file_get_contents($file));
283 283
             $this->getDbCommand()->setVersion($currentVersion, Migration::VERSION_STATUS_COMPLETE);
284 284
             $currentVersion = $currentVersion + $increment;
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
     public function update($upVersion = null, $force = false)
316 316
     {
317 317
         $versionInfo = $this->getCurrentVersion();
318
-        $version = intval($versionInfo['version']);
318
+        $version = intval($versionInfo[ 'version' ]);
319 319
         $increment = 1;
320 320
         if ($upVersion !== null && $upVersion < $version) {
321 321
             $increment = -1;
Please login to merge, or discard this patch.
tests/BaseDatabase.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
     protected function getExpectedUsersVersion0()
113 113
     {
114 114
         return [
115
-            ["id" => 1, "name" => 'John Doe', 'createdate' => '20160110'],
116
-            ["id" => 2, "name" => 'Jane Doe', 'createdate' => '20151230']
115
+            [ "id" => 1, "name" => 'John Doe', 'createdate' => '20160110' ],
116
+            [ "id" => 2, "name" => 'Jane Doe', 'createdate' => '20151230' ]
117 117
         ];
118 118
     }
119 119
 
120 120
     protected function getExpectedUsersVersion1()
121 121
     {
122 122
         return [
123
-            ["id" => 1, "name" => 'John Doe', 'createdate' => '2016-01-10'],
124
-            ["id" => 2, "name" => 'Jane Doe', 'createdate' => '2015-12-30']
123
+            [ "id" => 1, "name" => 'John Doe', 'createdate' => '2016-01-10' ],
124
+            [ "id" => 2, "name" => 'Jane Doe', 'createdate' => '2015-12-30' ]
125 125
         ];
126 126
     }
127 127
 
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
      */
132 132
     protected function assertVersion0()
133 133
     {
134
-        $version = $this->migrate->getDbDriver()->getScalar('select version from '. $this->migrationTable);
134
+        $version = $this->migrate->getDbDriver()->getScalar('select version from ' . $this->migrationTable);
135 135
         $this->assertEquals(0, $version);
136
-        $status = $this->migrate->getDbDriver()->getScalar('select status from '. $this->migrationTable);
136
+        $status = $this->migrate->getDbDriver()->getScalar('select status from ' . $this->migrationTable);
137 137
         $this->assertEquals(Migration::VERSION_STATUS_COMPLETE, $status);
138 138
 
139 139
         $iterator = $this->migrate->getDbDriver()->getIterator('select * from users');
@@ -141,14 +141,14 @@  discard block
 block discarded – undo
141 141
         $this->assertTrue($iterator->hasNext());
142 142
         $row = $iterator->moveNext();
143 143
         $this->assertEquals(
144
-            $this->getExpectedUsersVersion0()[0],
144
+            $this->getExpectedUsersVersion0()[ 0 ],
145 145
             $row->toArray()
146 146
         );
147 147
 
148 148
         $this->assertTrue($iterator->hasNext());
149 149
         $row = $iterator->moveNext();
150 150
         $this->assertEquals(
151
-            $this->getExpectedUsersVersion0()[1],
151
+            $this->getExpectedUsersVersion0()[ 1 ],
152 152
             $row->toArray()
153 153
         );
154 154
 
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
      */
168 168
     protected function assertVersion1()
169 169
     {
170
-        $version = $this->migrate->getDbDriver()->getScalar('select version from '. $this->migrationTable);
170
+        $version = $this->migrate->getDbDriver()->getScalar('select version from ' . $this->migrationTable);
171 171
         $this->assertEquals(1, $version);
172
-        $status = $this->migrate->getDbDriver()->getScalar('select status from '. $this->migrationTable);
172
+        $status = $this->migrate->getDbDriver()->getScalar('select status from ' . $this->migrationTable);
173 173
         $this->assertEquals(Migration::VERSION_STATUS_COMPLETE, $status);
174 174
 
175 175
         $iterator = $this->migrate->getDbDriver()->getIterator('select * from users');
@@ -177,14 +177,14 @@  discard block
 block discarded – undo
177 177
         $this->assertTrue($iterator->hasNext());
178 178
         $row = $iterator->moveNext();
179 179
         $this->assertEquals(
180
-            $this->getExpectedUsersVersion1()[0],
180
+            $this->getExpectedUsersVersion1()[ 0 ],
181 181
             $row->toArray()
182 182
         );
183 183
 
184 184
         $this->assertTrue($iterator->hasNext());
185 185
         $row = $iterator->moveNext();
186 186
         $this->assertEquals(
187
-            $this->getExpectedUsersVersion1()[1],
187
+            $this->getExpectedUsersVersion1()[ 1 ],
188 188
             $row->toArray()
189 189
         );
190 190
 
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
      */
204 204
     protected function assertVersion2()
205 205
     {
206
-        $version = $this->migrate->getDbDriver()->getScalar('select version from '. $this->migrationTable);
206
+        $version = $this->migrate->getDbDriver()->getScalar('select version from ' . $this->migrationTable);
207 207
         $this->assertEquals(2, $version);
208
-        $status = $this->migrate->getDbDriver()->getScalar('select status from '. $this->migrationTable);
208
+        $status = $this->migrate->getDbDriver()->getScalar('select status from ' . $this->migrationTable);
209 209
         $this->assertEquals(Migration::VERSION_STATUS_COMPLETE, $status);
210 210
 
211 211
         $iterator = $this->migrate->getDbDriver()->getIterator('select * from users');
@@ -213,14 +213,14 @@  discard block
 block discarded – undo
213 213
         $this->assertTrue($iterator->hasNext());
214 214
         $row = $iterator->moveNext();
215 215
         $this->assertEquals(
216
-            $this->getExpectedUsersVersion1()[0],
216
+            $this->getExpectedUsersVersion1()[ 0 ],
217 217
             $row->toArray()
218 218
         );
219 219
 
220 220
         $this->assertTrue($iterator->hasNext());
221 221
         $row = $iterator->moveNext();
222 222
         $this->assertEquals(
223
-            $this->getExpectedUsersVersion1()[1],
223
+            $this->getExpectedUsersVersion1()[ 1 ],
224 224
             $row->toArray()
225 225
         );
226 226
 
Please login to merge, or discard this patch.