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.

StaticMethodCallExpression   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 94
Duplicated Lines 24.47 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 14
lcom 1
cbo 5
dl 23
loc 94
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getName() 0 4 1
A getArguments() 0 4 1
A traverse() 0 4 1
A update() 11 11 4
A compileMember() 12 12 2
A updateClassValue() 0 4 1
A dataToSerialize() 0 4 1
A unserializeData() 0 4 1
A __clone() 0 6 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
3
namespace Pinq\Expressions;
4
5
/**
6
 * <code>
7
 * Class::Method('foo')
8
 * </code>
9
 *
10
 * @author Elliot Levin <[email protected]>
11
 */
12
class StaticMethodCallExpression extends StaticClassExpression
13
{
14
    /**
15
     * @var Expression
16
     */
17
    private $name;
18
19
    /**
20
     * @var ArgumentExpression[]
21
     */
22
    private $arguments;
23
24
    public function __construct(Expression $class, Expression $name, array $arguments = [])
25
    {
26
        parent::__construct($class);
27
        $this->name      = $name;
28
        $this->arguments = self::verifyAll($arguments, ArgumentExpression::getType());
29
    }
30
31
    /**
32
     * @return Expression
33
     */
34
    public function getName()
35
    {
36
        return $this->name;
37
    }
38
39
    /**
40
     * @return ArgumentExpression[]
41
     */
42
    public function getArguments()
43
    {
44
        return $this->arguments;
45
    }
46
47
    public function traverse(ExpressionWalker $walker)
48
    {
49
        return $walker->walkStaticMethodCall($this);
50
    }
51
52
    /**
53
     * @param Expression           $class
54
     * @param Expression           $name
55
     * @param ArgumentExpression[] $arguments
56
     *
57
     * @return self
58
     */
59 View Code Duplication
    public function update(Expression $class, Expression $name, array $arguments = [])
0 ignored issues
show
Duplication introduced by
This method 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...
60
    {
61
        if ($this->class === $class
62
                && $this->name === $name
63
                && $this->arguments === $arguments
64
        ) {
65
            return $this;
66
        }
67
68
        return new self($class, $name, $arguments);
69
    }
70
71 View Code Duplication
    protected function compileMember(&$code)
0 ignored issues
show
Duplication introduced by
This method 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...
72
    {
73
        if ($this->name instanceof ValueExpression) {
74
            $code .= $this->name->getValue();
75
        } else {
76
            $this->name->compileCode($code);
77
        }
78
79
        $code .= '(';
80
        $code .= implode(',', self::compileAll($this->arguments));
81
        $code .= ')';
82
    }
83
84
    protected function updateClassValue(Expression $class)
85
    {
86
        return new self($class, $this->name, $this->arguments);
87
    }
88
89
    protected function dataToSerialize()
90
    {
91
        return [$this->name, $this->arguments];
92
    }
93
94
    protected function unserializeData($data)
95
    {
96
        list($this->name, $this->arguments) = $data;
97
    }
98
99
    public function __clone()
100
    {
101
        $this->class     = clone $this->class;
102
        $this->name      = clone $this->name;
103
        $this->arguments = self::cloneAll($this->arguments);
104
    }
105
}
106