Completed
Push — resets ( d2f77b )
by Paul
02:06
created

Insert   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 38
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getLastInsertIdName() 0 8 2
A returning() 0 4 1
1
<?php
2
/**
3
 *
4
 * This file is part of Aura for PHP.
5
 *
6
 * @license http://opensource.org/licenses/bsd-license.php BSD
7
 *
8
 */
9
namespace Aura\SqlQuery\Pgsql;
10
11
use Aura\SqlQuery\Common;
12
13
/**
14
 *
15
 * An object for PgSQL INSERT queries.
16
 *
17
 * @package Aura.SqlQuery
18
 *
19
 */
20
class Insert extends Common\Insert implements Common\ReturningInterface
21
{
22
    /**
23
     *
24
     * Returns the proper name for passing to `PDO::lastInsertId()`.
25
     *
26
     * @param string $col The last insert ID column.
27
     *
28
     * @return string The sequence name "{$into_table}_{$col}_seq", or the
29
     * value from `$last_insert_id_names`.
30
     *
31
     */
32 2
    public function getLastInsertIdName($col)
33
    {
34 2
        $name = parent::getLastInsertIdName($col);
35 2
        if (! $name) {
36 1
            $name = "{$this->into}_{$col}_seq";
37 1
        }
38 2
        return $name;
39
    }
40
41
    /**
42
     *
43
     * Adds returning columns to the query.
44
     *
45
     * Multiple calls to returning() will append to the list of columns, not
46
     * overwrite the previous columns.
47
     *
48
     * @param array $cols The column(s) to add to the query.
49
     *
50
     * @return $this
51
     *
52
     */
53 1
    public function returning(array $cols)
54
    {
55 1
        return $this->addReturning($cols);
56
    }
57
}
58