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.

VariableExpression::__clone()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Pinq\Expressions;
4
5
/**
6
 * <code>
7
 * $I
8
 * </code>
9
 * @author Elliot Levin <[email protected]>
10
 */
11
class VariableExpression extends Expression
12
{
13
    /**
14
     * @var Expression
15
     */
16
    private $name;
17
18
    public function __construct(Expression $name)
19
    {
20
        $this->name = $name;
21
    }
22
23
    public function asEvaluator(IEvaluationContext $context = null)
24
    {
25
        $nameExpression = $this->name;
26
        if ($nameExpression instanceof ValueExpression) {
27
            return new VariableEvaluator($nameExpression->getValue(), $context);
28
        }
29
30
        return parent::asEvaluator($context);
31
    }
32
33
    public function traverse(ExpressionWalker $walker)
34
    {
35
        return $walker->walkVariable($this);
36
    }
37
38
    /**
39
     * @return Expression
40
     */
41
    public function getName()
42
    {
43
        return $this->name;
44
    }
45
46
    /**
47
     * @param Expression $name
48
     *
49
     * @return self
50
     */
51
    public function update(Expression $name)
52
    {
53
        if ($this->name === $name) {
54
            return $this;
55
        }
56
57
        return new self($name);
58
    }
59
60 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...
61
    {
62
        if ($this->name instanceof ValueExpression && self::isNormalSyntaxName($this->name->getValue())) {
63
            $code .= '$' . $this->name->getValue();
64
        } else {
65
            $code .= '${';
66
            $this->name->compileCode($code);
67
            $code .= '}';
68
        }
69
    }
70
71
    public function serialize()
72
    {
73
        return serialize($this->name);
74
    }
75
76
    public function unserialize($serialized)
77
    {
78
        $this->name = unserialize($serialized);
79
    }
80
81
    public function __clone()
82
    {
83
        $this->name = clone $this->name;
84
    }
85
}
86