Passed
Push — feature-FRAM-112-closure-filte... ( c8f14f )
by Vincent
06:52
created

VariableValue::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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