Completed
Push — 3.x ( e5eb1c...76cecd )
by Paul
9s
created

Insert::getLastInsertIdName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2
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 ReturningInterface
21
{
22
    use ReturningTrait;
23
24 7
    protected function build()
25
    {
26 7
        return parent::build()
27 7
            . $this->builder->buildReturning($this->returning);
0 ignored issues
show
Bug introduced by
The property builder does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
28
    }
29
30
    /**
31
     *
32
     * Returns the proper name for passing to `PDO::lastInsertId()`.
33
     *
34
     * @param string $col The last insert ID column.
35
     *
36
     * @return string The sequence name "{$into_table}_{$col}_seq", or the
37
     * value from `$last_insert_id_names`.
38
     *
39
     */
40 2
    public function getLastInsertIdName($col)
41
    {
42 2
        $name = parent::getLastInsertIdName($col);
43 2
        if (! $name) {
44 1
            $name = "{$this->into_raw}_{$col}_seq";
45
        }
46 2
        return $name;
47
    }
48
}
49