Completed
Push — master ( bfd6b1...8e3086 )
by Joao
01:44
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/Migration.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     /**
40 40
      * @var array
41 41
      */
42
-    protected $databases = [];
42
+    protected $databases = [ ];
43 43
     /**
44 44
      * @var string
45 45
      */
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function registerDatabase($scheme, $className)
73 73
     {
74
-        $this->databases[$scheme] = $className;
74
+        $this->databases[ $scheme ] = $className;
75 75
         return $this;
76 76
     }
77 77
 
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
      */
104 104
     protected function getDatabaseClassName()
105 105
     {
106
-        if (isset($this->databases[$this->uri->getScheme()])) {
107
-            return $this->databases[$this->uri->getScheme()];
106
+        if (isset($this->databases[ $this->uri->getScheme() ])) {
107
+            return $this->databases[ $this->uri->getScheme() ];
108 108
         }
109 109
         throw new DatabaseDoesNotRegistered(
110 110
             'Scheme "' . $this->uri->getScheme() . '" does not found. Did you registered it?'
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             . "/" . ($increment < 0 ? "down" : "up")
145 145
             . "/*.sql";
146 146
 
147
-        $result = array_filter(glob($filePattern), function ($file) use ($version) {
147
+        $result = array_filter(glob($filePattern), function($file) use ($version) {
148 148
             return preg_match("/^0*$version(-dev)?\.sql$/", basename($file));
149 149
         });
150 150
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
     public function reset($upVersion = null)
187 187
     {
188 188
         if ($this->callableProgress) {
189
-            call_user_func_array($this->callableProgress, ['reset', 0]);
189
+            call_user_func_array($this->callableProgress, [ 'reset', 0 ]);
190 190
         }
191 191
         $this->getDbCommand()->dropDatabase();
192 192
         $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'], 'partial') !== false && !$force) {
270
+        if (strpos($versionInfo[ '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, 'partial ' . ($increment>0 ? 'up' : 'down'));
281
+            $this->getDbCommand()->setVersion($currentVersion, 'partial ' . ($increment > 0 ? 'up' : 'down'));
282 282
             $this->getDbCommand()->executeSql(file_get_contents($file));
283 283
             $this->getDbCommand()->setVersion($currentVersion, '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.
src/Database/AbstractDatabase.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,15 +54,15 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function getVersion()
56 56
     {
57
-        $result = [];
57
+        $result = [ ];
58 58
         try {
59
-            $result['version'] = $this->getDbDriver()->getScalar('SELECT version FROM ' . $this->getMigrationTable());
59
+            $result[ 'version' ] = $this->getDbDriver()->getScalar('SELECT version FROM ' . $this->getMigrationTable());
60 60
         } catch (\Exception $ex) {
61 61
             throw new DatabaseNotVersionedException('This database does not have a migration version. Please use "migrate reset" or "migrate install" to create one.');
62 62
         }
63 63
 
64 64
         try {
65
-            $result['status'] = $this->getDbDriver()->getScalar('SELECT status FROM ' . $this->getMigrationTable());
65
+            $result[ 'status' ] = $this->getDbDriver()->getScalar('SELECT status FROM ' . $this->getMigrationTable());
66 66
         } catch (\Exception $ex) {
67 67
             throw new OldVersionSchemaException('This database does not have a migration version. Please use "migrate install" for update it.');
68 68
         }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     {
94 94
         // Get the version to check if exists
95 95
         $versionInfo = $this->getVersion();
96
-        if (empty($versionInfo['version'])) {
96
+        if (empty($versionInfo[ 'version' ])) {
97 97
             $this->getDbDriver()->execute("insert into " . $this->getMigrationTable() . " values(0, 'unknow')");
98 98
         }
99 99
     }
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
@@ -64,24 +64,24 @@  discard block
 block discarded – undo
64 64
     protected function getExpectedUsersVersion0()
65 65
     {
66 66
         return [
67
-            ["id" => 1, "name" => 'John Doe', 'createdate' => '20160110'],
68
-            ["id" => 2, "name" => 'Jane Doe', 'createdate' => '20151230']
67
+            [ "id" => 1, "name" => 'John Doe', 'createdate' => '20160110' ],
68
+            [ "id" => 2, "name" => 'Jane Doe', 'createdate' => '20151230' ]
69 69
         ];
70 70
     }
71 71
 
72 72
     protected function getExpectedUsersVersion1()
73 73
     {
74 74
         return [
75
-            ["id" => 1, "name" => 'John Doe', 'createdate' => '2016-01-10'],
76
-            ["id" => 2, "name" => 'Jane Doe', 'createdate' => '2015-12-30']
75
+            [ "id" => 1, "name" => 'John Doe', 'createdate' => '2016-01-10' ],
76
+            [ "id" => 2, "name" => 'Jane Doe', 'createdate' => '2015-12-30' ]
77 77
         ];
78 78
     }
79 79
 
80 80
     protected function assertVersion0()
81 81
     {
82
-        $version = $this->migrate->getDbDriver()->getScalar('select version from '. $this->migrationTable);
82
+        $version = $this->migrate->getDbDriver()->getScalar('select version from ' . $this->migrationTable);
83 83
         $this->assertEquals(0, $version);
84
-        $status = $this->migrate->getDbDriver()->getScalar('select status from '. $this->migrationTable);
84
+        $status = $this->migrate->getDbDriver()->getScalar('select status from ' . $this->migrationTable);
85 85
         $this->assertEquals('complete', $status);
86 86
 
87 87
         $iterator = $this->migrate->getDbDriver()->getIterator('select * from users');
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
         $this->assertTrue($iterator->hasNext());
90 90
         $row = $iterator->moveNext();
91 91
         $this->assertEquals(
92
-            $this->getExpectedUsersVersion0()[0],
92
+            $this->getExpectedUsersVersion0()[ 0 ],
93 93
             $row->toArray()
94 94
         );
95 95
 
96 96
         $this->assertTrue($iterator->hasNext());
97 97
         $row = $iterator->moveNext();
98 98
         $this->assertEquals(
99
-            $this->getExpectedUsersVersion0()[1],
99
+            $this->getExpectedUsersVersion0()[ 1 ],
100 100
             $row->toArray()
101 101
         );
102 102
 
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 
112 112
     protected function assertVersion1()
113 113
     {
114
-        $version = $this->migrate->getDbDriver()->getScalar('select version from '. $this->migrationTable);
114
+        $version = $this->migrate->getDbDriver()->getScalar('select version from ' . $this->migrationTable);
115 115
         $this->assertEquals(1, $version);
116
-        $status = $this->migrate->getDbDriver()->getScalar('select status from '. $this->migrationTable);
116
+        $status = $this->migrate->getDbDriver()->getScalar('select status from ' . $this->migrationTable);
117 117
         $this->assertEquals('complete', $status);
118 118
 
119 119
         $iterator = $this->migrate->getDbDriver()->getIterator('select * from users');
@@ -121,14 +121,14 @@  discard block
 block discarded – undo
121 121
         $this->assertTrue($iterator->hasNext());
122 122
         $row = $iterator->moveNext();
123 123
         $this->assertEquals(
124
-            $this->getExpectedUsersVersion1()[0],
124
+            $this->getExpectedUsersVersion1()[ 0 ],
125 125
             $row->toArray()
126 126
         );
127 127
 
128 128
         $this->assertTrue($iterator->hasNext());
129 129
         $row = $iterator->moveNext();
130 130
         $this->assertEquals(
131
-            $this->getExpectedUsersVersion1()[1],
131
+            $this->getExpectedUsersVersion1()[ 1 ],
132 132
             $row->toArray()
133 133
         );
134 134
 
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 
144 144
     protected function assertVersion2()
145 145
     {
146
-        $version = $this->migrate->getDbDriver()->getScalar('select version from '. $this->migrationTable);
146
+        $version = $this->migrate->getDbDriver()->getScalar('select version from ' . $this->migrationTable);
147 147
         $this->assertEquals(2, $version);
148
-        $status = $this->migrate->getDbDriver()->getScalar('select status from '. $this->migrationTable);
148
+        $status = $this->migrate->getDbDriver()->getScalar('select status from ' . $this->migrationTable);
149 149
         $this->assertEquals('complete', $status);
150 150
 
151 151
         $iterator = $this->migrate->getDbDriver()->getIterator('select * from users');
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
         $this->assertTrue($iterator->hasNext());
154 154
         $row = $iterator->moveNext();
155 155
         $this->assertEquals(
156
-            $this->getExpectedUsersVersion1()[0],
156
+            $this->getExpectedUsersVersion1()[ 0 ],
157 157
             $row->toArray()
158 158
         );
159 159
 
160 160
         $this->assertTrue($iterator->hasNext());
161 161
         $row = $iterator->moveNext();
162 162
         $this->assertEquals(
163
-            $this->getExpectedUsersVersion1()[1],
163
+            $this->getExpectedUsersVersion1()[ 1 ],
164 164
             $row->toArray()
165 165
         );
166 166
 
Please login to merge, or discard this patch.