Completed
Pull Request — master (#31)
by Joao
01:21
created
src/Database/PgsqlDatabase.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
     {
26 26
         $currentDbName = $dbDriver->getScalar(
27 27
             "SELECT datname FROM pg_catalog.pg_database WHERE lower(datname) = lower(:dbname)",
28
-            ['dbname' => $database]
28
+            [ 'dbname' => $database ]
29 29
         );
30 30
 
31 31
         if (empty($currentDbName)) {
Please login to merge, or discard this patch.
tests/SqlServerDatabaseTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@
 block discarded – undo
14 14
     public function getExpectedUsersVersion1()
15 15
     {
16 16
         return [
17
-            ["id" => 1, "name" => 'John Doe', 'createdate' => 'Jan 10 2016 12:00:00:AM'],
18
-            ["id" => 2, "name" => 'Jane Doe', 'createdate' => 'Dec 30 2015 12:00:00:AM']
17
+            [ "id" => 1, "name" => 'John Doe', 'createdate' => 'Jan 10 2016 12:00:00:AM' ],
18
+            [ "id" => 2, "name" => 'Jane Doe', 'createdate' => 'Dec 30 2015 12:00:00:AM' ]
19 19
         ];
20 20
     }
21 21
 
Please login to merge, or discard this patch.
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.
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.
src/Migration.php 1 patch
Spacing   +20 added lines, -20 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
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
      */
113 113
     protected function getDatabaseClassName()
114 114
     {
115
-        if (isset($this->databases[$this->uri->getScheme()])) {
116
-            return $this->databases[$this->uri->getScheme()];
115
+        if (isset($this->databases[ $this->uri->getScheme() ])) {
116
+            return $this->databases[ $this->uri->getScheme() ];
117 117
         }
118 118
         throw new DatabaseDoesNotRegistered(
119 119
             'Scheme "' . $this->uri->getScheme() . '" does not found. Did you registered it?'
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             . "/" . ($increment < 0 ? "down" : "up")
154 154
             . "/*.sql";
155 155
 
156
-        $result = array_filter(glob($filePattern), function ($file) use ($version) {
156
+        $result = array_filter(glob($filePattern), function($file) use ($version) {
157 157
             return preg_match("/^0*$version(-dev)?\.sql$/", basename($file));
158 158
         });
159 159
 
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
             return $data;
189 189
         }
190 190
 
191
-        $data["content"] = file_get_contents($file);
191
+        $data[ "content" ] = file_get_contents($file);
192 192
 
193
-        if (preg_match("/--\s*@description:\s*(?<name>.*)/", $data["content"], $description)) {
194
-            $data["description"] = $description["name"];
193
+        if (preg_match("/--\s*@description:\s*(?<name>.*)/", $data[ "content" ], $description)) {
194
+            $data[ "description" ] = $description[ "name" ];
195 195
         }
196 196
 
197
-        $data["exists"] = true;
198
-        $data["checksum"] = sha1($data["content"]);
197
+        $data[ "exists" ] = true;
198
+        $data[ "checksum" ] = sha1($data[ "content" ]);
199 199
 
200 200
         return $data;
201 201
     }
@@ -227,14 +227,14 @@  discard block
 block discarded – undo
227 227
         $fileInfo = $this->getFileContent($this->getBaseSql());
228 228
 
229 229
         if ($this->callableProgress) {
230
-            call_user_func_array($this->callableProgress, ['reset', 0, $fileInfo]);
230
+            call_user_func_array($this->callableProgress, [ 'reset', 0, $fileInfo ]);
231 231
         }
232 232
         $this->getDbCommand()->dropDatabase();
233 233
         $this->getDbCommand()->createDatabase();
234 234
         $this->getDbCommand()->createVersion();
235 235
 
236
-        if ($fileInfo["exists"]) {
237
-            $this->getDbCommand()->executeSql($fileInfo["content"]);
236
+        if ($fileInfo[ "exists" ]) {
237
+            $this->getDbCommand()->executeSql($fileInfo[ "content" ]);
238 238
         }
239 239
 
240 240
         $this->getDbCommand()->setVersion(0, Migration::VERSION_STATUS_COMPLETE);
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
     protected function migrate($upVersion, $increment, $force)
303 303
     {
304 304
         $versionInfo = $this->getCurrentVersion();
305
-        $currentVersion = intval($versionInfo['version']) + $increment;
305
+        $currentVersion = intval($versionInfo[ 'version' ]) + $increment;
306 306
 
307
-        if (strpos($versionInfo['status'], Migration::VERSION_STATUS_PARTIAL) !== false && !$force) {
307
+        if (strpos($versionInfo[ 'status' ], Migration::VERSION_STATUS_PARTIAL) !== false && !$force) {
308 308
             throw new DatabaseIsIncompleteException('Database was not fully updated. Use --force for migrate.');
309 309
         }
310 310
 
@@ -312,16 +312,16 @@  discard block
 block discarded – undo
312 312
         ) {
313 313
             $fileInfo = $this->getFileContent($this->getMigrationSql($currentVersion, $increment));
314 314
 
315
-            if (!$fileInfo["exists"]) {
315
+            if (!$fileInfo[ "exists" ]) {
316 316
                 break;
317 317
             }
318 318
 
319 319
             if ($this->callableProgress) {
320
-                call_user_func_array($this->callableProgress, ['migrate', $currentVersion, $fileInfo]);
320
+                call_user_func_array($this->callableProgress, [ 'migrate', $currentVersion, $fileInfo ]);
321 321
             }
322 322
 
323
-            $this->getDbCommand()->setVersion($currentVersion, Migration::VERSION_STATUS_PARTIAL . ' ' . ($increment>0 ? 'up' : 'down'));
324
-            $this->getDbCommand()->executeSql($fileInfo["content"]);
323
+            $this->getDbCommand()->setVersion($currentVersion, Migration::VERSION_STATUS_PARTIAL . ' ' . ($increment > 0 ? 'up' : 'down'));
324
+            $this->getDbCommand()->executeSql($fileInfo[ "content" ]);
325 325
             $this->getDbCommand()->setVersion($currentVersion, Migration::VERSION_STATUS_COMPLETE);
326 326
             $currentVersion = $currentVersion + $increment;
327 327
         }
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
     public function update($upVersion = null, $force = false)
358 358
     {
359 359
         $versionInfo = $this->getCurrentVersion();
360
-        $version = intval($versionInfo['version']);
360
+        $version = intval($versionInfo[ 'version' ]);
361 361
         $increment = 1;
362 362
         if ($upVersion !== null && $upVersion < $version) {
363 363
             $increment = -1;
Please login to merge, or discard this patch.