Completed
Push — master ( bd03b7...2e6f46 )
by Ondřej
03:14
created
src/Ivory/Connection/StatementExecution.php 1 patch
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -35,8 +35,7 @@  discard block
 block discarded – undo
35 35
     {
36 36
         if ($sqlFragmentPatternOrRecipe instanceof IRelationRecipe) {
37 37
             $recipe = $this->setupRecipe($sqlFragmentPatternOrRecipe, ...$fragmentsAndPositionalParamsAndNamedParamsMap);
38
-        }
39
-        else {
38
+        } else {
40 39
             $recipe = SqlRelationRecipe::fromFragments($sqlFragmentPatternOrRecipe, ...$fragmentsAndPositionalParamsAndNamedParamsMap);
41 40
         }
42 41
 
@@ -48,8 +47,7 @@  discard block
 block discarded – undo
48 47
     {
49 48
         if ($sqlFragmentPatternOrRecipe instanceof ICommandRecipe) {
50 49
             $recipe = $this->setupRecipe($sqlFragmentPatternOrRecipe, ...$fragmentsAndPositionalParamsAndNamedParamsMap);
51
-        }
52
-        else {
50
+        } else {
53 51
             $recipe = SqlCommandRecipe::fromFragments($sqlFragmentPatternOrRecipe, ...$fragmentsAndPositionalParamsAndNamedParamsMap);
54 52
         }
55 53
 
@@ -66,8 +64,7 @@  discard block
 block discarded – undo
66 64
                 }
67 65
                 $namedParamsMap = $args[0];
68 66
                 $recipe->setParams($namedParamsMap);
69
-            }
70
-            else {
67
+            } else {
71 68
                 throw new \InvalidArgumentException('Too many arguments given.');
72 69
             }
73 70
         }
@@ -80,8 +77,7 @@  discard block
 block discarded – undo
80 77
         $result = $this->executeRawStatement($sqlQuery, $resultHandler);
81 78
         if ($result instanceof IQueryResult) {
82 79
             return $result;
83
-        }
84
-        else {
80
+        } else {
85 81
             trigger_error(
86 82
                 'The supplied SQL statement was supposed to be a query, but it did not return a result set. ' .
87 83
                 'Returning an empty relation. Consider calling command() or rawCommand() instead. ' .
@@ -97,8 +93,7 @@  discard block
 block discarded – undo
97 93
         $result = $this->executeRawStatement($sqlCommand, $resultHandler);
98 94
         if ($result instanceof ICommandResult) {
99 95
             return $result;
100
-        }
101
-        else {
96
+        } else {
102 97
             trigger_error(
103 98
                 'The supplied SQL statement was supposed to be a command, but it returned a result set. ' .
104 99
                 'Returning an empty result. Consider calling query() or rawQuery() instead. ' .
@@ -218,8 +213,7 @@  discard block
 block discarded – undo
218 213
         if ($resNotice !== $connNotice) {
219 214
             $this->connCtl->setLastNotice($resNotice);
220 215
             return $resNotice;
221
-        }
222
-        else {
216
+        } else {
223 217
             return null;
224 218
         }
225 219
     }
Please login to merge, or discard this patch.
src/Ivory/Connection/Connection.php 1 patch
Indentation   +264 added lines, -264 removed lines patch added patch discarded remove patch
@@ -10,103 +10,103 @@  discard block
 block discarded – undo
10 10
 // TODO: consider introducing factory methods for abbreviating relation creating; e.g., new QueryRelation($conn, $query)
11 11
 class Connection implements IConnection
12 12
 {
13
-	use NotSerializable; // TODO: implement connection serialization instead of giving up
14
-
15
-	private $name;
16
-	private $connCtl;
17
-	private $typeCtl;
18
-	private $stmtExec;
19
-	private $copyCtl;
20
-	private $txCtl;
21
-	private $ipcCtl;
22
-
23
-	private $config;
24
-
25
-
26
-	/**
27
-	 * @param string $name name for the connection
28
-	 * @param ConnectionParameters|array|string $params either a connection parameters object, or an associative array
29
-	 *                                                    of parameters for {@link ConnectionParameters::__construct()},
30
-	 *                                                    or a URL for {@link ConnectionParameters::fromUrl()},
31
-	 *                                                    or a PostgreSQL connection string (see {@link pg_connect()})
32
-	 */
33
-	public function __construct($name, $params)
34
-	{
35
-		$this->name = $name;
36
-		$this->connCtl = new ConnectionControl($params); // TODO: extract all usages of ConnectionControl::requireConnection() - consider introducing an interface specifying the method, named like PGSQLDriver or ConnectionManager or ConnectionPool
37
-		$this->typeCtl = new TypeControl($this, $this->connCtl);
38
-		$this->stmtExec = new StatementExecution($this->connCtl, $this->typeCtl);
39
-		$this->copyCtl = new CopyControl();
40
-		$this->txCtl = new TransactionControl($this->connCtl, $this->stmtExec);
41
-		$this->ipcCtl = new IPCControl($this->connCtl);
42
-		$this->config = new ConnConfig($this->connCtl, $this->stmtExec, $this->txCtl);
43
-	}
44
-
45
-	final public function getName()
46
-	{
47
-		return $this->name;
48
-	}
49
-
50
-	final public function getConfig()
51
-	{
52
-		return $this->config;
53
-	}
54
-
55
-
56
-	//region Connection Control
57
-
58
-	public function getParameters()
59
-	{
60
-		return $this->connCtl->getParameters();
61
-	}
62
-
63
-	public function isConnected()
64
-	{
65
-		return $this->connCtl->isConnected();
66
-	}
67
-
68
-	public function isConnectedWait()
69
-	{
70
-		return $this->connCtl->isConnectedWait();
71
-	}
72
-
73
-	public function connect()
74
-	{
75
-		return $this->connCtl->connect();
76
-	}
77
-
78
-	public function connectWait()
79
-	{
80
-		return $this->connCtl->connectWait();
81
-	}
82
-
83
-	public function disconnect()
84
-	{
85
-		return $this->connCtl->disconnect();
86
-	}
87
-
88
-	//endregion
89
-
90
-	//region Type Control
91
-
92
-	public function getTypeRegister()
93
-	{
94
-		return $this->typeCtl->getTypeRegister();
95
-	}
96
-
97
-	public function getTypeDictionary()
98
-	{
99
-		return $this->typeCtl->getTypeDictionary();
100
-	}
101
-
102
-	public function flushTypeDictionary()
103
-	{
104
-		$this->typeCtl->flushTypeDictionary();
105
-	}
106
-
107
-	//endregion
108
-
109
-	//region Statement Execution
13
+    use NotSerializable; // TODO: implement connection serialization instead of giving up
14
+
15
+    private $name;
16
+    private $connCtl;
17
+    private $typeCtl;
18
+    private $stmtExec;
19
+    private $copyCtl;
20
+    private $txCtl;
21
+    private $ipcCtl;
22
+
23
+    private $config;
24
+
25
+
26
+    /**
27
+     * @param string $name name for the connection
28
+     * @param ConnectionParameters|array|string $params either a connection parameters object, or an associative array
29
+     *                                                    of parameters for {@link ConnectionParameters::__construct()},
30
+     *                                                    or a URL for {@link ConnectionParameters::fromUrl()},
31
+     *                                                    or a PostgreSQL connection string (see {@link pg_connect()})
32
+     */
33
+    public function __construct($name, $params)
34
+    {
35
+        $this->name = $name;
36
+        $this->connCtl = new ConnectionControl($params); // TODO: extract all usages of ConnectionControl::requireConnection() - consider introducing an interface specifying the method, named like PGSQLDriver or ConnectionManager or ConnectionPool
37
+        $this->typeCtl = new TypeControl($this, $this->connCtl);
38
+        $this->stmtExec = new StatementExecution($this->connCtl, $this->typeCtl);
39
+        $this->copyCtl = new CopyControl();
40
+        $this->txCtl = new TransactionControl($this->connCtl, $this->stmtExec);
41
+        $this->ipcCtl = new IPCControl($this->connCtl);
42
+        $this->config = new ConnConfig($this->connCtl, $this->stmtExec, $this->txCtl);
43
+    }
44
+
45
+    final public function getName()
46
+    {
47
+        return $this->name;
48
+    }
49
+
50
+    final public function getConfig()
51
+    {
52
+        return $this->config;
53
+    }
54
+
55
+
56
+    //region Connection Control
57
+
58
+    public function getParameters()
59
+    {
60
+        return $this->connCtl->getParameters();
61
+    }
62
+
63
+    public function isConnected()
64
+    {
65
+        return $this->connCtl->isConnected();
66
+    }
67
+
68
+    public function isConnectedWait()
69
+    {
70
+        return $this->connCtl->isConnectedWait();
71
+    }
72
+
73
+    public function connect()
74
+    {
75
+        return $this->connCtl->connect();
76
+    }
77
+
78
+    public function connectWait()
79
+    {
80
+        return $this->connCtl->connectWait();
81
+    }
82
+
83
+    public function disconnect()
84
+    {
85
+        return $this->connCtl->disconnect();
86
+    }
87
+
88
+    //endregion
89
+
90
+    //region Type Control
91
+
92
+    public function getTypeRegister()
93
+    {
94
+        return $this->typeCtl->getTypeRegister();
95
+    }
96
+
97
+    public function getTypeDictionary()
98
+    {
99
+        return $this->typeCtl->getTypeDictionary();
100
+    }
101
+
102
+    public function flushTypeDictionary()
103
+    {
104
+        $this->typeCtl->flushTypeDictionary();
105
+    }
106
+
107
+    //endregion
108
+
109
+    //region Statement Execution
110 110
 
111 111
     public function query($sqlFragmentPatternOrRecipe, ...$fragmentsAndPositionalParamsAndNamedParamsMap): IQueryResult
112 112
     {
@@ -118,177 +118,177 @@  discard block
 block discarded – undo
118 118
         return $this->stmtExec->command($sqlFragmentPatternOrRecipe, ...$fragmentsAndPositionalParamsAndNamedParamsMap);
119 119
     }
120 120
 
121
-	public function rawQuery(string $sqlQuery): IQueryResult
122
-	{
123
-		return $this->stmtExec->rawQuery($sqlQuery);
124
-	}
121
+    public function rawQuery(string $sqlQuery): IQueryResult
122
+    {
123
+        return $this->stmtExec->rawQuery($sqlQuery);
124
+    }
125 125
 
126 126
     public function rawCommand(string $sqlCommand): ICommandResult
127
-   	{
128
-   		return $this->stmtExec->rawCommand($sqlCommand);
129
-   	}
127
+        {
128
+            return $this->stmtExec->rawCommand($sqlCommand);
129
+        }
130 130
 
131
-	public function rawMultiStatement($sqlStatements)
132
-	{
133
-		return $this->stmtExec->rawMultiStatement($sqlStatements);
134
-	}
131
+    public function rawMultiStatement($sqlStatements)
132
+    {
133
+        return $this->stmtExec->rawMultiStatement($sqlStatements);
134
+    }
135 135
 
136
-	public function runScript(string $sqlScript)
137
-	{
138
-		return $this->stmtExec->runScript($sqlScript);
139
-	}
136
+    public function runScript(string $sqlScript)
137
+    {
138
+        return $this->stmtExec->runScript($sqlScript);
139
+    }
140 140
 
141 141
     public function getStatementExceptionFactory(): StatementExceptionFactory
142
-   	{
143
-   		return $this->stmtExec->getStatementExceptionFactory();
144
-   	}
145
-
146
-	//endregion
147
-
148
-	//region Copy Control
149
-
150
-	public function copyFromFile($file, $table, $columns = null, $options = [])
151
-	{
152
-		return $this->copyCtl->copyFromFile($file, $table, $columns, $options);
153
-	}
154
-
155
-	public function copyFromProgram($program, $table, $columns = null, $options = [])
156
-	{
157
-		return $this->copyCtl->copyFromProgram($program, $table, $columns, $options);
158
-	}
159
-
160
-	public function copyFromInput($table, $columns = null, $options = [])
161
-	{
162
-		return $this->copyCtl->copyFromInput($table, $columns, $options);
163
-	}
164
-
165
-	public function copyToFile($file, $tableOrQuery, $columns = null, $options = [])
166
-	{
167
-		return $this->copyCtl->copyToFile($file, $tableOrQuery, $columns, $options);
168
-	}
169
-
170
-	public function copyToProgram($program, $tableOrQuery, $columns = null, $options = [])
171
-	{
172
-		return $this->copyCtl->copyToProgram($program, $tableOrQuery, $columns, $options);
173
-	}
174
-
175
-	public function copyToArray($table, $options = [])
176
-	{
177
-		return $this->copyCtl->copyToArray($table, $options);
178
-	}
179
-
180
-	//endregion
181
-
182
-	//region Transaction Control
183
-
184
-	public function inTransaction()
185
-	{
186
-		return $this->txCtl->inTransaction();
187
-	}
188
-
189
-	public function startTransaction($transactionOptions = 0)
190
-	{
191
-		return $this->txCtl->startTransaction($transactionOptions);
192
-	}
193
-
194
-	public function setupTransaction($transactionOptions)
195
-	{
196
-		$this->txCtl->setupTransaction($transactionOptions);
197
-	}
198
-
199
-	public function setupSubsequentTransactions($transactionOptions)
200
-	{
201
-		$this->txCtl->setupSubsequentTransactions($transactionOptions);
202
-	}
203
-
204
-	public function commit()
205
-	{
206
-		return $this->txCtl->commit();
207
-	}
208
-
209
-	public function rollback()
210
-	{
211
-		return $this->txCtl->rollback();
212
-	}
213
-
214
-	public function savepoint($name)
215
-	{
216
-		$this->txCtl->savepoint($name);
217
-	}
218
-
219
-	public function rollbackToSavepoint($name)
220
-	{
221
-		$this->txCtl->rollbackToSavepoint($name);
222
-	}
223
-
224
-	public function releaseSavepoint($name)
225
-	{
226
-		$this->txCtl->releaseSavepoint($name);
227
-	}
228
-
229
-	public function setTransactionSnapshot($snapshotId)
230
-	{
231
-		return $this->txCtl->setTransactionSnapshot($snapshotId);
232
-	}
233
-
234
-	public function exportTransactionSnapshot()
235
-	{
236
-		return $this->txCtl->exportTransactionSnapshot();
237
-	}
238
-
239
-	public function prepareTransaction($name)
240
-	{
241
-		return $this->txCtl->prepareTransaction($name);
242
-	}
243
-
244
-	public function commitPreparedTransaction($name)
245
-	{
246
-		$this->txCtl->commitPreparedTransaction($name);
247
-	}
248
-
249
-	public function rollbackPreparedTransaction($name)
250
-	{
251
-		$this->txCtl->rollbackPreparedTransaction($name);
252
-	}
253
-
254
-	public function listPreparedTransactions()
255
-	{
256
-		return $this->txCtl->listPreparedTransactions();
257
-	}
258
-
259
-	//endregion
260
-
261
-	//region IPC Control
262
-
263
-	public function getBackendPID()
264
-	{
265
-		return $this->ipcCtl->getBackendPID();
266
-	}
267
-
268
-	public function notify($channel, $payload = null)
269
-	{
270
-		$this->ipcCtl->notify($channel, $payload);
271
-	}
272
-
273
-	public function listen($channel)
274
-	{
275
-		$this->ipcCtl->listen($channel);
276
-	}
277
-
278
-	public function unlisten($channel)
279
-	{
280
-		$this->ipcCtl->unlisten($channel);
281
-	}
282
-
283
-	public function unlistenAll()
284
-	{
285
-		$this->ipcCtl->unlistenAll();
286
-	}
287
-
288
-	public function pollNotification()
289
-	{
290
-		return $this->ipcCtl->pollNotification();
291
-	}
292
-
293
-	//endregion
142
+        {
143
+            return $this->stmtExec->getStatementExceptionFactory();
144
+        }
145
+
146
+    //endregion
147
+
148
+    //region Copy Control
149
+
150
+    public function copyFromFile($file, $table, $columns = null, $options = [])
151
+    {
152
+        return $this->copyCtl->copyFromFile($file, $table, $columns, $options);
153
+    }
154
+
155
+    public function copyFromProgram($program, $table, $columns = null, $options = [])
156
+    {
157
+        return $this->copyCtl->copyFromProgram($program, $table, $columns, $options);
158
+    }
159
+
160
+    public function copyFromInput($table, $columns = null, $options = [])
161
+    {
162
+        return $this->copyCtl->copyFromInput($table, $columns, $options);
163
+    }
164
+
165
+    public function copyToFile($file, $tableOrQuery, $columns = null, $options = [])
166
+    {
167
+        return $this->copyCtl->copyToFile($file, $tableOrQuery, $columns, $options);
168
+    }
169
+
170
+    public function copyToProgram($program, $tableOrQuery, $columns = null, $options = [])
171
+    {
172
+        return $this->copyCtl->copyToProgram($program, $tableOrQuery, $columns, $options);
173
+    }
174
+
175
+    public function copyToArray($table, $options = [])
176
+    {
177
+        return $this->copyCtl->copyToArray($table, $options);
178
+    }
179
+
180
+    //endregion
181
+
182
+    //region Transaction Control
183
+
184
+    public function inTransaction()
185
+    {
186
+        return $this->txCtl->inTransaction();
187
+    }
188
+
189
+    public function startTransaction($transactionOptions = 0)
190
+    {
191
+        return $this->txCtl->startTransaction($transactionOptions);
192
+    }
193
+
194
+    public function setupTransaction($transactionOptions)
195
+    {
196
+        $this->txCtl->setupTransaction($transactionOptions);
197
+    }
198
+
199
+    public function setupSubsequentTransactions($transactionOptions)
200
+    {
201
+        $this->txCtl->setupSubsequentTransactions($transactionOptions);
202
+    }
203
+
204
+    public function commit()
205
+    {
206
+        return $this->txCtl->commit();
207
+    }
208
+
209
+    public function rollback()
210
+    {
211
+        return $this->txCtl->rollback();
212
+    }
213
+
214
+    public function savepoint($name)
215
+    {
216
+        $this->txCtl->savepoint($name);
217
+    }
218
+
219
+    public function rollbackToSavepoint($name)
220
+    {
221
+        $this->txCtl->rollbackToSavepoint($name);
222
+    }
223
+
224
+    public function releaseSavepoint($name)
225
+    {
226
+        $this->txCtl->releaseSavepoint($name);
227
+    }
228
+
229
+    public function setTransactionSnapshot($snapshotId)
230
+    {
231
+        return $this->txCtl->setTransactionSnapshot($snapshotId);
232
+    }
233
+
234
+    public function exportTransactionSnapshot()
235
+    {
236
+        return $this->txCtl->exportTransactionSnapshot();
237
+    }
238
+
239
+    public function prepareTransaction($name)
240
+    {
241
+        return $this->txCtl->prepareTransaction($name);
242
+    }
243
+
244
+    public function commitPreparedTransaction($name)
245
+    {
246
+        $this->txCtl->commitPreparedTransaction($name);
247
+    }
248
+
249
+    public function rollbackPreparedTransaction($name)
250
+    {
251
+        $this->txCtl->rollbackPreparedTransaction($name);
252
+    }
253
+
254
+    public function listPreparedTransactions()
255
+    {
256
+        return $this->txCtl->listPreparedTransactions();
257
+    }
258
+
259
+    //endregion
260
+
261
+    //region IPC Control
262
+
263
+    public function getBackendPID()
264
+    {
265
+        return $this->ipcCtl->getBackendPID();
266
+    }
267
+
268
+    public function notify($channel, $payload = null)
269
+    {
270
+        $this->ipcCtl->notify($channel, $payload);
271
+    }
272
+
273
+    public function listen($channel)
274
+    {
275
+        $this->ipcCtl->listen($channel);
276
+    }
277
+
278
+    public function unlisten($channel)
279
+    {
280
+        $this->ipcCtl->unlisten($channel);
281
+    }
282
+
283
+    public function unlistenAll()
284
+    {
285
+        $this->ipcCtl->unlistenAll();
286
+    }
287
+
288
+    public function pollNotification()
289
+    {
290
+        return $this->ipcCtl->pollNotification();
291
+    }
292
+
293
+    //endregion
294 294
 }
Please login to merge, or discard this patch.