Processor::processInsertGetId()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 4
1
<?php
2
namespace Childish\query;
3
4
/**
5
 * Processor
6
 *
7
 * @author    Pu ShaoWei <[email protected]>
8
 * @date      2017/12/7
9
 * @package   Childish
10
 * @version   1.0
11
 */
12
class Processor
13
{
14
    /**
15
     * Process the results of a "select" query.
16
     *
17
     * @param  \Childish\query\Builder  $query
18
     * @param  array  $results
19
     * @return array
20
     */
21
    public function processSelect(Builder $query, $results)
0 ignored issues
show
Unused Code introduced by
The parameter $query is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23
        return $results;
24
    }
25
26
    /**
27
     * Process an  "insert get ID" query.
28
     *
29
     * @param  \Childish\query\Builder  $query
30
     * @param  string  $sql
31
     * @param  array   $values
32
     * @param  string  $sequence
33
     * @return int
34
     */
35
    public function processInsertGetId(Builder $query, $sql, $values, $sequence = null)
36
    {
37
        $query->getConnection()->insert($sql, $values);
38
39
        $id = $query->getConnection()->getPdo()->lastInsertId($sequence);
40
41
        return is_numeric($id) ? (int) $id : $id;
42
    }
43
44
    /**
45
     * Process the results of a column listing query.
46
     *
47
     * @param  array  $results
48
     * @return array
49
     */
50
    public function processColumnListing($results)
51
    {
52
        return $results;
53
    }
54
}