Completed
Push — 3.x-builder ( 46541a...6c1cc6 )
by Paul
01:49
created

ReturningTrait::returning()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
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
/**
12
 *
13
 * Common code for RETURNING clauses.
14
 *
15
 * @package Aura.SqlQuery
16
 *
17
 */
18
trait ReturningTrait
19
{
20
    /**
21
     *
22
     * The columns to be returned.
23
     *
24
     * @var array
25
     *
26
     */
27
    protected $returning = [];
28
29
    /**
30
     *
31
     * Adds returning columns to the query.
32
     *
33
     * Multiple calls to returning() will append to the list of columns, not
34
     * overwrite the previous columns.
35
     *
36
     * @param array $cols The column(s) to add to the query.
37
     *
38
     * @return $this
39
     *
40
     */
41 3
    public function returning(array $cols)
42
    {
43 3
        foreach ($cols as $col) {
44 3
            $this->returning[] = $this->quoter->quoteNamesIn($col);
0 ignored issues
show
Bug introduced by
The property quoter 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...
45 3
        }
46 3
        return $this;
47
    }
48
}
49