Passed
Pull Request — 2.1 (#71)
by Vincent
14:21 queued 08:17
created

VariableValue   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 22
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 7 2
A __construct() 0 3 1
1
<?php
2
3
namespace Bdf\Prime\Query\Closure\Value;
4
5
use ReflectionFunction;
6
7
/**
8
 * Get value from bound variable
9
 */
10
final class VariableValue implements ComparisonValueInterface
11
{
12
    private string $variable;
13
14
    /**
15
     * @param string $variable The variable name
16
     */
17 6
    public function __construct(string $variable)
18
    {
19 6
        $this->variable = $variable;
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 6
    public function get(ReflectionFunction $reflection)
26
    {
27 6
        if ($this->variable === 'this') {
28 1
            return $reflection->getClosureThis();
29
        }
30
31 5
        return $reflection->getStaticVariables()[$this->variable];
32
    }
33
}
34