Passed
Pull Request — master (#2007)
by
unknown
02:49
created

AdapterWrapper::hasPrimaryKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 3
crap 2
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace Phinx\Db\Adapter;
9
10
use Phinx\Db\Table\Column;
11
use Phinx\Db\Table\Table;
12
use Phinx\Migration\MigrationInterface;
13
use Symfony\Component\Console\Input\InputInterface;
14
use Symfony\Component\Console\Output\OutputInterface;
15
16
/**
17
 * Adapter Wrapper.
18
 *
19
 * Proxy commands through to another adapter, allowing modification of
20
 * parameters during calls.
21
 *
22
 * @author Woody Gilk <[email protected]>
23
 */
24
abstract class AdapterWrapper implements AdapterInterface, WrapperInterface
25
{
26
    /**
27
     * @var \Phinx\Db\Adapter\AdapterInterface
28
     */
29
    protected $adapter;
30
31
    /**
32
     * @inheritDoc
33
     */
34
    public function __construct(AdapterInterface $adapter)
35
    {
36
        $this->setAdapter($adapter);
37
    }
38
39
    /**
40
     * @inheritDoc
41
     */
42
    public function setAdapter(AdapterInterface $adapter)
43
    {
44
        $this->adapter = $adapter;
45
46
        return $this;
47
    }
48
49
    /**
50
     * @inheritDoc
51
     */
52
    public function getAdapter()
53
    {
54
        return $this->adapter;
55
    }
56
57 36
    /**
58
     * @inheritDoc
59 36
     */
60 36
    public function setOptions(array $options)
61
    {
62
        $this->adapter->setOptions($options);
63
64
        return $this;
65 36
    }
66
67 36
    /**
68 36
     * @inheritDoc
69
     */
70
    public function getOptions()
71
    {
72
        return $this->adapter->getOptions();
73
    }
74 24
75
    /**
76 24
     * @inheritDoc
77
     */
78
    public function hasOption($name)
79
    {
80
        return $this->adapter->hasOption($name);
81
    }
82
83
    /**
84
     * @inheritDoc
85
     */
86
    public function getOption($name)
87
    {
88
        return $this->adapter->getOption($name);
89
    }
90
91 2
    /**
92
     * @inheritDoc
93 2
     */
94
    public function setInput(InputInterface $input)
95
    {
96
        $this->adapter->setInput($input);
97
98
        return $this;
99 8
    }
100
101 8
    /**
102
     * @inheritDoc
103
     */
104
    public function getInput()
105
    {
106
        return $this->adapter->getInput();
107 19
    }
108
109 19
    /**
110
     * @inheritDoc
111
     */
112
    public function setOutput(OutputInterface $output)
113
    {
114
        $this->adapter->setOutput($output);
115 5
116
        return $this;
117 5
    }
118 5
119
    /**
120
     * @inheritDoc
121
     */
122
    public function getOutput()
123
    {
124
        return $this->adapter->getOutput();
125
    }
126
127
    /**
128
     * @inheritDoc
129
     */
130
    public function getColumnForType($columnName, $type, array $options)
131
    {
132 5
        return $this->adapter->getColumnForType($columnName, $type, $options);
133
    }
134 5
135 5
    /**
136
     * @inheritDoc
137
     */
138
    public function connect()
139
    {
140
        $this->getAdapter()->connect();
141 5
    }
142
143 5
    /**
144
     * @inheritDoc
145
     */
146
    public function disconnect()
147
    {
148
        $this->getAdapter()->disconnect();
149
    }
150
151
    /**
152
     * @inheritDoc
153
     */
154
    public function execute($sql, array $params = [])
155
    {
156
        return $this->getAdapter()->execute($sql, $params);
157 5
    }
158
159 5
    /**
160 5
     * @inheritDoc
161
     */
162
    public function query($sql, array $params = [])
163
    {
164
        return $this->getAdapter()->query($sql, $params);
165 2
    }
166
167 2
    /**
168
     * @inheritDoc
169
     */
170
    public function insert(Table $table, $row)
171
    {
172
        $this->getAdapter()->insert($table, $row);
173
    }
174
175
    /**
176
     * @inheritDoc
177
     */
178
    public function bulkinsert(Table $table, $rows)
179
    {
180
        $this->getAdapter()->bulkinsert($table, $rows);
181
    }
182
183
    /**
184
     * @inheritDoc
185
     */
186
    public function fetchRow($sql)
187
    {
188
        return $this->getAdapter()->fetchRow($sql);
189 3
    }
190
191 3
    /**
192 3
     * @inheritDoc
193
     */
194
    public function fetchAll($sql)
195
    {
196
        return $this->getAdapter()->fetchAll($sql);
197
    }
198
199
    /**
200
     * @inheritDoc
201
     */
202
    public function getVersions()
203
    {
204
        return $this->getAdapter()->getVersions();
205 1
    }
206
207 1
    /**
208
     * @inheritDoc
209
     */
210
    public function getVersionLog()
211
    {
212
        return $this->getAdapter()->getVersionLog();
213 5
    }
214
215 5
    /**
216
     * @inheritDoc
217
     */
218
    public function migrated(MigrationInterface $migration, $direction, $startTime, $endTime)
219
    {
220
        $this->getAdapter()->migrated($migration, $direction, $startTime, $endTime);
221 5
222
        return $this;
223 5
    }
224
225
    /**
226
     * @inheritDoc
227
     */
228
    public function toggleBreakpoint(MigrationInterface $migration)
229 5
    {
230
        $this->getAdapter()->toggleBreakpoint($migration);
231 5
232 5
        return $this;
233
    }
234
235
    /**
236
     * @inheritDoc
237
     */
238 1
    public function resetAllBreakpoints()
239
    {
240 1
        return $this->getAdapter()->resetAllBreakpoints();
241 1
    }
242
243
    /**
244
     * @inheritDoc
245
     */
246
    public function setBreakpoint(MigrationInterface $migration)
247 1
    {
248
        $this->getAdapter()->setBreakpoint($migration);
249 1
250
        return $this;
251
    }
252
253
    /**
254
     * @inheritDoc
255
     */
256
    public function unsetBreakpoint(MigrationInterface $migration)
257
    {
258
        $this->getAdapter()->unsetBreakpoint($migration);
259
260
        return $this;
261
    }
262
263
    /**
264
     * @inheritDoc
265
     */
266
    public function createSchemaTable()
267
    {
268
        $this->getAdapter()->createSchemaTable();
269
    }
270
271
    /**
272
     * @inheritDoc
273
     */
274
    public function getColumnTypes()
275
    {
276
        return $this->getAdapter()->getColumnTypes();
277
    }
278
279 4
    /**
280
     * @inheritDoc
281 4
     */
282
    public function isValidColumnType(Column $column)
283
    {
284
        return $this->getAdapter()->isValidColumnType($column);
285
    }
286
287 5
    /**
288
     * @inheritDoc
289 5
     */
290
    public function hasTransactions()
291
    {
292
        return $this->getAdapter()->hasTransactions();
293
    }
294
295 5
    /**
296
     * @inheritDoc
297 5
     */
298 5
    public function beginTransaction()
299
    {
300
        $this->getAdapter()->beginTransaction();
301
    }
302
303 5
    /**
304
     * @inheritDoc
305 5
     */
306 5
    public function commitTransaction()
307
    {
308
        $this->getAdapter()->commitTransaction();
309
    }
310
311
    /**
312
     * @inheritDoc
313
     */
314
    public function rollbackTransaction()
315
    {
316
        $this->getAdapter()->rollbackTransaction();
317
    }
318
319
    /**
320
     * @inheritDoc
321
     */
322
    public function quoteTableName($tableName)
323
    {
324
        return $this->getAdapter()->quoteTableName($tableName);
325
    }
326
327
    /**
328
     * @inheritDoc
329
     */
330
    public function quoteColumnName($columnName)
331
    {
332
        return $this->getAdapter()->quoteColumnName($columnName);
333
    }
334
335 5
    /**
336
     * @inheritDoc
337 5
     */
338
    public function hasTable($tableName)
339
    {
340
        return $this->getAdapter()->hasTable($tableName);
341
    }
342
343 6
    /**
344
     * @inheritDoc
345 6
     */
346 6
    public function createTable(Table $table, array $columns = [], array $indexes = [])
347
    {
348
        $this->getAdapter()->createTable($table, $columns, $indexes);
349
    }
350
351 4
    /**
352
     * @inheritDoc
353 4
     */
354 4
    public function getColumns($tableName)
355
    {
356
        return $this->getAdapter()->getColumns($tableName);
357
    }
358
359 4
    /**
360
     * @inheritDoc
361 4
     */
362 4
    public function hasColumn($tableName, $columnName)
363
    {
364
        return $this->getAdapter()->hasColumn($tableName, $columnName);
365
    }
366
367
    /**
368
     * @inheritDoc
369
     */
370
    public function hasIndex($tableName, $columns)
371
    {
372
        return $this->getAdapter()->hasIndex($tableName, $columns);
373
    }
374
375 1
    /**
376
     * @inheritDoc
377 1
     */
378
    public function hasIndexByName($tableName, $indexName)
379
    {
380
        return $this->getAdapter()->hasIndexByName($tableName, $indexName);
381
    }
382
383 4
    /**
384
     * @inheritDoc
385 4
     */
386
    public function hasPrimaryKey($tableName, $columns, $constraint = null)
387
    {
388
        return $this->getAdapter()->hasPrimaryKey($tableName, $columns, $constraint);
389
    }
390
391 4
    /**
392
     * @inheritDoc
393 4
     */
394 4
    public function hasForeignKey($tableName, $columns, $constraint = null)
395
    {
396
        return $this->getAdapter()->hasForeignKey($tableName, $columns, $constraint);
397
    }
398
399 4
    /**
400
     * @inheritDoc
401 4
     */
402 4
    public function getSqlType($type, $limit = null)
403
    {
404
        return $this->getAdapter()->getSqlType($type, $limit);
405
    }
406
407 1
    /**
408
     * @inheritDoc
409 1
     */
410
    public function createDatabase($name, $options = [])
411
    {
412
        $this->getAdapter()->createDatabase($name, $options);
413
    }
414
415 4
    /**
416
     * @inheritDoc
417 4
     */
418 4
    public function hasDatabase($name)
419
    {
420
        return $this->getAdapter()->hasDatabase($name);
421
    }
422
423 1
    /**
424
     * @inheritDoc
425 1
     */
426
    public function dropDatabase($name)
427
    {
428
        $this->getAdapter()->dropDatabase($name);
429
    }
430
431
    /**
432
     * @inheritDoc
433
     */
434
    public function createSchema($schemaName = 'public')
435
    {
436
        $this->getAdapter()->createSchema($schemaName);
437
    }
438
439
    /**
440
     * @inheritDoc
441
     */
442
    public function dropSchema($schemaName)
443
    {
444
        $this->getAdapter()->dropSchema($schemaName);
445
    }
446
447 1
    /**
448
     * @inheritDoc
449 1
     */
450 1
    public function truncateTable($tableName)
451
    {
452
        $this->getAdapter()->truncateTable($tableName);
453
    }
454
455 1
    /**
456
     * @inheritDoc
457 1
     */
458 1
    public function castToBool($value)
459
    {
460
        return $this->getAdapter()->castToBool($value);
461
    }
462
463 4
    /**
464
     * @return \PDO
465 4
     */
466
    public function getConnection()
467
    {
468
        return $this->getAdapter()->getConnection();
0 ignored issues
show
Bug introduced by
The method getConnection() does not exist on Phinx\Db\Adapter\AdapterInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Phinx\Db\Adapter\AbstractAdapter. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

468
        return $this->getAdapter()->/** @scrutinizer ignore-call */ getConnection();
Loading history...
469
    }
470
471 4
    /**
472
     * @inheritDoc
473 4
     */
474 4
    public function executeActions(Table $table, array $actions)
475
    {
476
        $this->getAdapter()->executeActions($table, $actions);
477
    }
478
479 4
    /**
480
     * @inheritDoc
481 4
     */
482 4
    public function getQueryBuilder()
483
    {
484
        return $this->getAdapter()->getQueryBuilder();
485
    }
486
}
487