GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

OnDuplicateKeyUpdateRule::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace PhpBoot\DB\rules\insert;
3
4
use PhpBoot\DB\DB;
5
use PhpBoot\DB\impls\OnDuplicateKeyUpdateImpl;
6
use PhpBoot\DB\rules\basic\BasicRule;
7
use PhpBoot\DB\rules\basic\ExecRule;
8
use PhpBoot\DB\impls\InsertImpl;
9
use PhpBoot\DB\impls\ValuesImpl;
10
11
require_once dirname(__DIR__).'/impls.php';
12
require_once __DIR__.'/basic.php';
13
14
class InsertRule extends BasicRule
15
{
16
    /**
17
     * 
18
     * insertInto('table')->values([1,2]) => "INSERT INTO table VALUES(1,2)"
19
     * @param string $table
20
     * @return \PhpBoot\DB\rules\insert\ValuesRule
21
     */
22 8
    public function insertInto($table) {
23 8
        InsertImpl::insertInto($this->context, $table);
24 8
        return new ValuesRule($this->context);
25
    }
26
}
27
class ValuesRule extends BasicRule
28
{
29
    /**
30
     *
31
     * insertInto('table')->values([1,2]) => "INSERT INTO table VALUES(1,2)"
32
     * insertInto('table')->values(['a'=>1, 'b'=>Sql::raw('now()')]) => "INSERT INTO table(a,b) VALUES(1,now())"
33
     * @param array $values
34
     * @return \PhpBoot\DB\rules\insert\OnDuplicateKeyUpdateRule
35
     */
36 5
    public function values(array $values) {
37 5
        ValuesImpl::values($this->context, $values);
38 5
        return new OnDuplicateKeyUpdateRule($this->context);
39
    }
40
41
    /**
42
     * insertInto('table')->batchValues([[1,2],[3,4]]) => "INSERT INTO table VALUES(1,2), (3,2)"
43
     *
44
     * @param array $values
45
     * @return \PhpBoot\DB\rules\insert\OnDuplicateKeyUpdateRule
46
     */
47 3
    public function batchValues(array $values){
48 3
        ValuesImpl::batchValues($this->context, $values);
49 3
        return new OnDuplicateKeyUpdateRule($this->context);
50
    }
51
}
52
53
class OnDuplicateKeyUpdateRule extends ExecRule
54
{
55 8
    public function __construct($context)
56
    {
57 8
        parent::__construct($context);
58 8
        $this->impl = new OnDuplicateKeyUpdateImpl();
59 8
    }
60
61
//    /**
62
//     *
63
//     * insertInto('table')
64
//     *      ->values(['a'=>1, 'b'=>Sql::raw('now()')])
65
//     *      ->onDuplicateKeyUpdate('a', Sql::raw('a+1'))
66
//     *  => "INSERT INTO table(a,b) VALUES(1,now()) ON DUPLICATE KEY UPDATE a=a+1"
67
//     *
68
//     * @param string $column
69
//     * @param mixed $value
70
//     * @return \PhpBoot\DB\rules\basic\ExecRule
71
//     */
72
//    public function onDuplicateKeyUpdate($column, $value) {
73
//        $this->impl->set($this->context, $column, $value);
74
//        return new ExecRule($this->context);
75
//    }
76
77
//    /**
78
//     *
79
//     * insertInto('table')
80
//     *      ->values(['a'=>1, 'b'=>Sql::raw('now()')])
81
//     *      ->onDuplicateKeyUpdateArgs(['a'=>Sql::raw('a+1')])
82
//     *  => "INSERT INTO table(a,b) VALUES(1,now()) ON DUPLICATE KEY UPDATE a=a+1"
83
//     *
84
//     * @param string $column
85
//     * @param mixed $value
86
//     * @return \PhpBoot\DB\rules\basic\ExecRule
87
//     */
88
//    public function onDuplicateKeyUpdateArgs($values) {
89
//        $this->impl->setArgs($this->context, $values);
90
//        return new ExecRule($this->context);
91
//    }
92
93
    /**
94
     *
95
     *  insertInto('table')
96
     *      ->values(['a'=>1, 'b'=>Sql::raw('now()')])
97
     *      ->onDuplicateKeyUpdate(['a'=>Sql::raw('a+1')])
98
     *  => "INSERT INTO table(a,b) VALUES(1,now()) ON DUPLICATE KEY UPDATE a=a+1"
99
     *
100
     * insertInto('table')
101
     *      ->values(['a'=>1, 'b'=>Sql::raw('now()')])
102
     *      ->onDuplicateKeyUpdate('a=a+1')
103
     *  => "INSERT INTO table(a,b) VALUES(1,now()) ON DUPLICATE KEY UPDATE a=a+1"
104
     *
105
     * @param string $column
0 ignored issues
show
Bug introduced by
There is no parameter named $column. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
106
     * @param mixed $value
0 ignored issues
show
Bug introduced by
There is no parameter named $value. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
107
     * @return \PhpBoot\DB\rules\basic\ExecRule
108
     */
109 1
    public function onDuplicateKeyUpdate($expr, $_=null) {
0 ignored issues
show
Unused Code introduced by
The parameter $_ 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...
110 1
        $this->impl->set($this->context, $expr, array_slice(func_get_args(), 1));
111 1
        return new ExecRule($this->context);
112
    }
113
    private $impl;
114
}