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.
Passed
Push — master ( 17036d...efc942 )
by cao
03:02
created

ValuesRule   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A values() 0 4 1
A batchValues() 0 4 1
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 14 and the first side effect is on line 11.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
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
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
54
{
55 8
    public function __construct($context)
56
    {
57 8
        parent::__construct($context);
58 8
        $this->impl = new OnDuplicateKeyUpdateImpl();
59 8
    }
60
61
//    /**
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
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
//    /**
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
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
}