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.

FunctionCallExpression   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 85
Duplicated Lines 25.88 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 4
dl 22
loc 85
rs 10
c 0
b 0
f 0

9 Methods

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