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.

UpdateSetRule   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A set() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace PhpBoot\DB\rules\update;
3
use PhpBoot\DB\Context;
4
use PhpBoot\DB\rules\basic\BasicRule;
5
use PhpBoot\DB\rules\basic\WhereRule;
6
use PhpBoot\DB\impls\UpdateSetImpl;
7
use PhpBoot\DB\impls\UpdateImpl;
8
9
10
require_once dirname(__DIR__).'/impls.php';
11
require_once __DIR__.'/basic.php';
12
13
class UpdateRule extends BasicRule
14
{
15
    /**
16
     * update('table')->set('a', 1) => "UPDATE table SET a=1"
17
     * @param string $table
18
     * @return \PhpBoot\DB\rules\update\UpdateSetRule
19
     */
20 11
    public function update($table) {
21 11
        UpdateImpl::update($this->context, $table);
22 11
        return new UpdateSetRule($this->context);
23
    }
24
}
25
26 View Code Duplication
class UpdateSetRule extends BasicRule
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
{
28 11
    public function __construct($context){
29 11
        parent::__construct($context);
30 11
        $this->impl = new UpdateSetImpl();
31 11
    }
32
    /**
33
     * update('table')->set(['a'=>1]) => "UPDATE table SET a=1"
34
35
     * update('table')->set('a=?',1) => "UPDATE table SET a=1"
36
     * @param array|string $expr
37
     * @param mixed $_
38
     * @return UpdateSetWhereRule
39
     */
40 11
    public function set($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...
41 11
        $this->impl->set($this->context, $expr, array_slice(func_get_args(), 1));
42 11
        return new UpdateSetWhereRule($this->context, $this->impl);
43
    }
44
    private $impl;
45
}
46
47 View Code Duplication
class UpdateSetWhereRule extends WhereRule
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
{
49 11
    public function __construct(Context $context, UpdateSetImpl $impl){
50 11
        parent::__construct($context);
51 11
        $this->impl = $impl;
52 11
    }
53
    /**
54
     * update('table')->set(['a'=>1]) => "UPDATE table SET a=1"
55
     * update('table')->set('a=?',1) => "UPDATE table SET a=1"
56
     * @param array|string $expr
57
     * @param mixed $_
58
     * @return UpdateSetWhereRule
59
     */
60
    public function set($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...
61
        $this->impl->set($this->context, $expr, array_slice(func_get_args(), 1));
62
        return new UpdateSetWhereRule($this->context, $this->impl);
63
    }
64
    private $impl;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
65
}
66
67