Completed
Pull Request — master (#1393)
by
unknown
03:29
created

AdapterWrapper::hasPrimaryKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 0
cp 0
cc 1
nc 1
nop 3
crap 2
1
<?php
2
/**
3
 * Phinx
4
 *
5
 * (The MIT license)
6
 * Copyright (c) 2015 Rob Morgan
7
 *
8
 * Permission is hereby granted, free of charge, to any person obtaining a copy
9
 * of this software and associated * documentation files (the "Software"), to
10
 * deal in the Software without restriction, including without limitation the
11
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12
 * sell copies of the Software, and to permit persons to whom the Software is
13
 * furnished to do so, subject to the following conditions:
14
 *
15
 * The above copyright notice and this permission notice shall be included in
16
 * all copies or substantial portions of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24
 * IN THE SOFTWARE.
25
 *
26
 * @package    Phinx
27
 * @subpackage Phinx\Db\Adapter
28
 */
29
namespace Phinx\Db\Adapter;
30
31
use Phinx\Db\Table\Column;
32
use Phinx\Db\Table\Table;
33
use Phinx\Migration\MigrationInterface;
34
use Symfony\Component\Console\Input\InputInterface;
35
use Symfony\Component\Console\Output\OutputInterface;
36
37
/**
38
 * Adapter Wrapper.
39
 *
40
 * Proxy commands through to another adapter, allowing modification of
41
 * parameters during calls.
42
 *
43
 * @author Woody Gilk <[email protected]>
44
 */
45
abstract class AdapterWrapper implements AdapterInterface, WrapperInterface
46
{
47
    /**
48
     * @var \Phinx\Db\Adapter\AdapterInterface
49
     */
50
    protected $adapter;
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function __construct(AdapterInterface $adapter)
56
    {
57 36
        $this->setAdapter($adapter);
58
    }
59 36
60 36
    /**
61
     * {@inheritdoc}
62
     */
63
    public function setAdapter(AdapterInterface $adapter)
64
    {
65 36
        $this->adapter = $adapter;
66
67 36
        return $this;
68 36
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73
    public function getAdapter()
74 24
    {
75
        return $this->adapter;
76 24
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81
    public function setOptions(array $options)
82
    {
83
        $this->adapter->setOptions($options);
84
85
        return $this;
86
    }
87
88
    /**
89
     * {@inheritdoc}
90
     */
91 2
    public function getOptions()
92
    {
93 2
        return $this->adapter->getOptions();
94
    }
95
96
    /**
97
     * {@inheritdoc}
98
     */
99 8
    public function hasOption($name)
100
    {
101 8
        return $this->adapter->hasOption($name);
102
    }
103
104
    /**
105
     * {@inheritdoc}
106
     */
107 19
    public function getOption($name)
108
    {
109 19
        return $this->adapter->getOption($name);
110
    }
111
112
    /**
113
     * {@inheritdoc}
114
     */
115 5
    public function setInput(InputInterface $input)
116
    {
117 5
        $this->adapter->setInput($input);
118 5
119
        return $this;
120
    }
121
122
    /**
123
     * {@inheritdoc}
124
     */
125
    public function getInput()
126
    {
127
        return $this->adapter->getInput();
128
    }
129
130
    /**
131
     * {@inheritdoc}
132 5
     */
133
    public function setOutput(OutputInterface $output)
134 5
    {
135 5
        $this->adapter->setOutput($output);
136
137
        return $this;
138
    }
139
140
    /**
141 5
     * {@inheritdoc}
142
     */
143 5
    public function getOutput()
144
    {
145
        return $this->adapter->getOutput();
146
    }
147
148
    /**
149
     * {@inheritdoc}
150
     */
151
    public function connect()
152
    {
153
        $this->getAdapter()->connect();
154
    }
155
156
    /**
157 5
     * {@inheritdoc}
158
     */
159 5
    public function disconnect()
160 5
    {
161
        $this->getAdapter()->disconnect();
162
    }
163
164
    /**
165 2
     * {@inheritdoc}
166
     */
167 2
    public function execute($sql)
168
    {
169
        return $this->getAdapter()->execute($sql);
170
    }
171
172
    /**
173
     * {@inheritdoc}
174
     */
175
    public function query($sql)
176
    {
177
        return $this->getAdapter()->query($sql);
178
    }
179
180
    /**
181
     * {@inheritdoc}
182
     */
183
    public function insert(Table $table, $row)
184
    {
185
        $this->getAdapter()->insert($table, $row);
186
    }
187
188
    /**
189 3
     * {@inheritdoc}
190
     */
191 3
    public function bulkinsert(Table $table, $rows)
192 3
    {
193
        $this->getAdapter()->bulkinsert($table, $rows);
194
    }
195
196
    /**
197
     * {@inheritdoc}
198
     */
199
    public function fetchRow($sql)
200
    {
201
        return $this->getAdapter()->fetchRow($sql);
202
    }
203
204
    /**
205 1
     * {@inheritdoc}
206
     */
207 1
    public function fetchAll($sql)
208
    {
209
        return $this->getAdapter()->fetchAll($sql);
210
    }
211
212
    /**
213 5
     * {@inheritdoc}
214
     */
215 5
    public function getVersions()
216
    {
217
        return $this->getAdapter()->getVersions();
218
    }
219
220
    /**
221 5
     * {@inheritdoc}
222
     */
223 5
    public function getVersionLog()
224
    {
225
        return $this->getAdapter()->getVersionLog();
226
    }
227
228
    /**
229 5
     * {@inheritdoc}
230
     */
231 5
    public function migrated(MigrationInterface $migration, $direction, $startTime, $endTime)
232 5
    {
233
        $this->getAdapter()->migrated($migration, $direction, $startTime, $endTime);
234
235
        return $this;
236
    }
237
238 1
    /**
239
     * {@inheritdoc}
240 1
     */
241 1
    public function toggleBreakpoint(MigrationInterface $migration)
242
    {
243
        $this->getAdapter()->toggleBreakpoint($migration);
244
245
        return $this;
246
    }
247 1
248
    /**
249 1
     * {@inheritdoc}
250
     */
251
    public function resetAllBreakpoints()
252
    {
253
        return $this->getAdapter()->resetAllBreakpoints();
254
    }
255
256
    /**
257
     * {@inheritdoc}
258
     */
259
    public function hasSchemaTable()
260
    {
261
        return $this->getAdapter()->hasSchemaTable();
0 ignored issues
show
Deprecated Code introduced by
The method Phinx\Db\Adapter\Adapter...rface::hasSchemaTable() has been deprecated with message: use hasTable instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
262
    }
263
264
    /**
265
     * {@inheritdoc}
266
     */
267
    public function createSchemaTable()
268
    {
269
        $this->getAdapter()->createSchemaTable();
270
    }
271
272
    /**
273
     * {@inheritdoc}
274
     */
275
    public function getColumnTypes()
276
    {
277
        return $this->getAdapter()->getColumnTypes();
278
    }
279 4
280
    /**
281 4
     * {@inheritdoc}
282
     */
283
    public function isValidColumnType(Column $column)
284
    {
285
        return $this->getAdapter()->isValidColumnType($column);
286
    }
287 5
288
    /**
289 5
     * {@inheritdoc}
290
     */
291
    public function hasTransactions()
292
    {
293
        return $this->getAdapter()->hasTransactions();
294
    }
295 5
296
    /**
297 5
     * {@inheritdoc}
298 5
     */
299
    public function beginTransaction()
300
    {
301
        $this->getAdapter()->beginTransaction();
302
    }
303 5
304
    /**
305 5
     * {@inheritdoc}
306 5
     */
307
    public function commitTransaction()
308
    {
309
        $this->getAdapter()->commitTransaction();
310
    }
311
312
    /**
313
     * {@inheritdoc}
314
     */
315
    public function rollbackTransaction()
316
    {
317
        $this->getAdapter()->rollbackTransaction();
318
    }
319
320
    /**
321
     * {@inheritdoc}
322
     */
323
    public function quoteTableName($tableName)
324
    {
325
        return $this->getAdapter()->quoteTableName($tableName);
326
    }
327
328
    /**
329
     * {@inheritdoc}
330
     */
331
    public function quoteColumnName($columnName)
332
    {
333
        return $this->getAdapter()->quoteColumnName($columnName);
334
    }
335 5
336
    /**
337 5
     * {@inheritdoc}
338
     */
339
    public function hasTable($tableName)
340
    {
341
        return $this->getAdapter()->hasTable($tableName);
342
    }
343 6
344
    /**
345 6
     * {@inheritdoc}
346 6
     */
347
    public function createTable(Table $table, array $columns = [], array $indexes = [])
348
    {
349
        $this->getAdapter()->createTable($table, $columns, $indexes);
350
    }
351 4
352
    /**
353 4
     * {@inheritdoc}
354 4
     */
355
    public function changeTable(Table $table, array $newOptions)
356
    {
357
        $this->getAdapter()->changeTable($table, $newOptions);
358
    }
359 4
360
    /**
361 4
     * {@inheritdoc}
362 4
     */
363
    public function getColumns($tableName)
364
    {
365
        return $this->getAdapter()->getColumns($tableName);
366
    }
367
368
    /**
369
     * {@inheritdoc}
370
     */
371
    public function hasColumn($tableName, $columnName)
372
    {
373
        return $this->getAdapter()->hasColumn($tableName, $columnName);
374
    }
375 1
376
    /**
377 1
     * {@inheritdoc}
378
     */
379
    public function hasIndex($tableName, $columns)
380
    {
381
        return $this->getAdapter()->hasIndex($tableName, $columns);
382
    }
383 4
384
    /**
385 4
     * {@inheritdoc}
386
     */
387
    public function hasIndexByName($tableName, $indexName)
388
    {
389
        return $this->getAdapter()->hasIndexByName($tableName, $indexName);
390
    }
391 4
392
    /**
393 4
     * {@inheritdoc}
394 4
     */
395
    public function hasPrimaryKey($tableName, $columns, $constraint = null)
396
    {
397
        return $this->getAdapter()->hasPrimaryKey($tableName, $columns, $constraint);
398
    }
399 4
400
    /**
401 4
     * {@inheritdoc}
402 4
     */
403
    public function hasForeignKey($tableName, $columns, $constraint = null)
404
    {
405
        return $this->getAdapter()->hasForeignKey($tableName, $columns, $constraint);
406
    }
407 1
408
    /**
409 1
     * {@inheritdoc}
410
     */
411
    public function getSqlType($type, $limit = null)
412
    {
413
        return $this->getAdapter()->getSqlType($type, $limit);
414
    }
415 4
416
    /**
417 4
     * {@inheritdoc}
418 4
     */
419
    public function createDatabase($name, $options = [])
420
    {
421
        $this->getAdapter()->createDatabase($name, $options);
422
    }
423 1
424
    /**
425 1
     * {@inheritdoc}
426
     */
427
    public function hasDatabase($name)
428
    {
429
        $this->getAdapter()->hasDatabase($name);
430
    }
431
432
    /**
433
     * {@inheritdoc}
434
     */
435
    public function dropDatabase($name)
436
    {
437
        $this->getAdapter()->dropDatabase($name);
438
    }
439
440
    /**
441
     * {@inheritdoc}
442
     */
443
    public function createSchema($schemaName = 'public')
444
    {
445
        $this->getAdapter()->createSchema($schemaName);
446
    }
447 1
448
    /**
449 1
     * {@inheritdoc}
450 1
     */
451
    public function dropSchema($schemaName)
452
    {
453
        $this->getAdapter()->dropSchema($schemaName);
454
    }
455 1
456
    /**
457 1
     * {@inheritdoc}
458 1
     */
459
    public function truncateTable($tableName)
460
    {
461
        $this->getAdapter()->truncateTable($tableName);
462
    }
463 4
464
    /**
465 4
     * {@inheritdoc}
466
     */
467
    public function castToBool($value)
468
    {
469
        return $this->getAdapter()->castToBool($value);
470
    }
471 4
472
    /**
473 4
     * {@inheritdoc}
474 4
     */
475
    public function getConnection()
476
    {
477
        return $this->getAdapter()->getConnection();
0 ignored issues
show
Bug introduced by
The method getConnection() does not exist on Phinx\Db\Adapter\AdapterInterface. Did you maybe mean connect()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
478
    }
479 4
480
    /**
481 4
     * {@inheritdoc}
482 4
     */
483
    public function executeActions(Table $table, array $actions)
484
    {
485
        $this->getAdapter()->executeActions($table, $actions);
486
    }
487
488
    /**
489
     * {@inheritdoc}
490
     */
491
    public function getQueryBuilder()
492
    {
493
        return $this->getAdapter()->getQueryBuilder();
494
    }
495
}
496