Passed
Push — master ( 86c63e...a506e2 )
by Joao
01:10 queued 10s
created
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.
tests/BaseDatabase.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -119,23 +119,23 @@  discard block
 block discarded – undo
119 119
     protected function getExpectedUsersVersion0()
120 120
     {
121 121
         return [
122
-            ["id" => 1, "name" => 'John Doe', 'createdate' => '20160110'],
123
-            ["id" => 2, "name" => 'Jane Doe', 'createdate' => '20151230']
122
+            [ "id" => 1, "name" => 'John Doe', 'createdate' => '20160110' ],
123
+            [ "id" => 2, "name" => 'Jane Doe', 'createdate' => '20151230' ]
124 124
         ];
125 125
     }
126 126
 
127 127
     protected function getExpectedUsersVersion1()
128 128
     {
129 129
         return [
130
-            ["id" => 1, "name" => 'John Doe', 'createdate' => '2016-01-10'],
131
-            ["id" => 2, "name" => 'Jane Doe', 'createdate' => '2015-12-30']
130
+            [ "id" => 1, "name" => 'John Doe', 'createdate' => '2016-01-10' ],
131
+            [ "id" => 2, "name" => 'Jane Doe', 'createdate' => '2015-12-30' ]
132 132
         ];
133 133
     }
134 134
 
135 135
     protected function getExpectedPostsVersion2()
136 136
     {
137 137
         return [
138
-            ["id" => 1, "userid" => 1, "title" => 'Testing', 'post' => "<!-- wp:paragraph -->\\n<p>This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:</p>\\n<!-- /wp:paragraph -->\\n\\n<!-- wp:quote -->\\n<blockquote class=\"wp-block-quote\"><p>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like pi&#241;a coladas. (And gettin' caught in the rain.)</p></blockquote>\\n<!-- /wp:quote -->\\n\\n<!-- wp:paragraph -->\\n<p>...or something like this:</p>\\n<!-- /wp:paragraph -->\\n\\n<!-- wp:quote -->\\n<blockquote class=\"wp-block-quote\"><p>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</p></blockquote>\\n<!-- /wp:quote -->\\n\\n<!-- wp:paragraph -->\\n<p>As a new WordPress user, you should go to <a href=\"http://home.home.lcl/wordpress/wp-admin/\">your dashboard</a> to delete this page and create new pages for your content. Have fun!</p>\\n<!-- /wp:paragraph -->"],
138
+            [ "id" => 1, "userid" => 1, "title" => 'Testing', 'post' => "<!-- wp:paragraph -->\\n<p>This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:</p>\\n<!-- /wp:paragraph -->\\n\\n<!-- wp:quote -->\\n<blockquote class=\"wp-block-quote\"><p>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like pi&#241;a coladas. (And gettin' caught in the rain.)</p></blockquote>\\n<!-- /wp:quote -->\\n\\n<!-- wp:paragraph -->\\n<p>...or something like this:</p>\\n<!-- /wp:paragraph -->\\n\\n<!-- wp:quote -->\\n<blockquote class=\"wp-block-quote\"><p>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</p></blockquote>\\n<!-- /wp:quote -->\\n\\n<!-- wp:paragraph -->\\n<p>As a new WordPress user, you should go to <a href=\"http://home.home.lcl/wordpress/wp-admin/\">your dashboard</a> to delete this page and create new pages for your content. Have fun!</p>\\n<!-- /wp:paragraph -->" ],
139 139
         ];
140 140
     }
141 141
 
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
      */
146 146
     protected function assertVersion0()
147 147
     {
148
-        $version = $this->migrate->getDbDriver()->getScalar('select version from '. $this->migrationTable);
148
+        $version = $this->migrate->getDbDriver()->getScalar('select version from ' . $this->migrationTable);
149 149
         $this->assertEquals(0, $version);
150
-        $status = $this->migrate->getDbDriver()->getScalar('select status from '. $this->migrationTable);
150
+        $status = $this->migrate->getDbDriver()->getScalar('select status from ' . $this->migrationTable);
151 151
         $this->assertEquals(Migration::VERSION_STATUS_COMPLETE, $status);
152 152
 
153 153
         $iterator = $this->migrate->getDbDriver()->getIterator('select * from users');
@@ -155,14 +155,14 @@  discard block
 block discarded – undo
155 155
         $this->assertTrue($iterator->hasNext());
156 156
         $row = $iterator->moveNext();
157 157
         $this->assertEquals(
158
-            $this->getExpectedUsersVersion0()[0],
158
+            $this->getExpectedUsersVersion0()[ 0 ],
159 159
             $row->toArray()
160 160
         );
161 161
 
162 162
         $this->assertTrue($iterator->hasNext());
163 163
         $row = $iterator->moveNext();
164 164
         $this->assertEquals(
165
-            $this->getExpectedUsersVersion0()[1],
165
+            $this->getExpectedUsersVersion0()[ 1 ],
166 166
             $row->toArray()
167 167
         );
168 168
 
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
      */
182 182
     protected function assertVersion1()
183 183
     {
184
-        $version = $this->migrate->getDbDriver()->getScalar('select version from '. $this->migrationTable);
184
+        $version = $this->migrate->getDbDriver()->getScalar('select version from ' . $this->migrationTable);
185 185
         $this->assertEquals(1, $version);
186
-        $status = $this->migrate->getDbDriver()->getScalar('select status from '. $this->migrationTable);
186
+        $status = $this->migrate->getDbDriver()->getScalar('select status from ' . $this->migrationTable);
187 187
         $this->assertEquals(Migration::VERSION_STATUS_COMPLETE, $status);
188 188
 
189 189
         $iterator = $this->migrate->getDbDriver()->getIterator('select * from users');
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
         $this->assertTrue($iterator->hasNext());
192 192
         $row = $iterator->moveNext();
193 193
         $this->assertEquals(
194
-            $this->getExpectedUsersVersion1()[0],
194
+            $this->getExpectedUsersVersion1()[ 0 ],
195 195
             $row->toArray()
196 196
         );
197 197
 
198 198
         $this->assertTrue($iterator->hasNext());
199 199
         $row = $iterator->moveNext();
200 200
         $this->assertEquals(
201
-            $this->getExpectedUsersVersion1()[1],
201
+            $this->getExpectedUsersVersion1()[ 1 ],
202 202
             $row->toArray()
203 203
         );
204 204
 
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
      */
218 218
     protected function assertVersion2()
219 219
     {
220
-        $version = $this->migrate->getDbDriver()->getScalar('select version from '. $this->migrationTable);
220
+        $version = $this->migrate->getDbDriver()->getScalar('select version from ' . $this->migrationTable);
221 221
         $this->assertEquals(2, $version);
222
-        $status = $this->migrate->getDbDriver()->getScalar('select status from '. $this->migrationTable);
222
+        $status = $this->migrate->getDbDriver()->getScalar('select status from ' . $this->migrationTable);
223 223
         $this->assertEquals(Migration::VERSION_STATUS_COMPLETE, $status);
224 224
 
225 225
         // Users
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
         $this->assertTrue($iterator->hasNext());
229 229
         $row = $iterator->moveNext();
230 230
         $this->assertEquals(
231
-            $this->getExpectedUsersVersion1()[0],
231
+            $this->getExpectedUsersVersion1()[ 0 ],
232 232
             $row->toArray()
233 233
         );
234 234
 
235 235
         $this->assertTrue($iterator->hasNext());
236 236
         $row = $iterator->moveNext();
237 237
         $this->assertEquals(
238
-            $this->getExpectedUsersVersion1()[1],
238
+            $this->getExpectedUsersVersion1()[ 1 ],
239 239
             $row->toArray()
240 240
         );
241 241
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
         $this->assertTrue($iterator->hasNext());
248 248
         $row = $iterator->moveNext();
249 249
         $this->assertEquals(
250
-            $this->getExpectedPostsVersion2()[0],
250
+            $this->getExpectedPostsVersion2()[ 0 ],
251 251
             $row->toArray()
252 252
         );
253 253
     }
Please login to merge, or discard this patch.