Completed
Push — master ( 30de07...1799ff )
by Дмитрий
03:30
created

ConstFetch   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A compile() 0 19 4
1
<?php
2
3
namespace PHPSA\Compiler\Expression;
4
5
use PHPSA\CompiledExpression;
6
use PHPSA\Context;
7
use PhpParser\Node;
8
9
class ConstFetch extends AbstractExpressionCompiler
10
{
11
    protected $name = 'PhpParser\Node\Expr\ConstFetch';
12
13
    /**
14
     * true, CONSTANTNAME, ...
15
     *
16
     * @param \PhpParser\Node\Expr\ConstFetch $expr
17
     * @param Context $context
18
     * @return CompiledExpression
19
     */
20 14
    protected function compile($expr, Context $context)
21
    {
22 14
        $compiler = $context->getExpressionCompiler();
23
24 14
        if ($expr->name instanceof Node\Name) {
25 14
            if ($expr->name->parts[0] === 'true') {
0 ignored issues
show
Deprecated Code introduced by
The property PhpParser\Node\Name::$parts has been deprecated with message: Avoid directly accessing $parts, use methods instead.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
26 10
                return new CompiledExpression(CompiledExpression::BOOLEAN, true);
27
            }
28
29 9
            if ($expr->name->parts[0] === 'false') {
0 ignored issues
show
Deprecated Code introduced by
The property PhpParser\Node\Name::$parts has been deprecated with message: Avoid directly accessing $parts, use methods instead.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
30 5
                return new CompiledExpression(CompiledExpression::BOOLEAN, false);
31
            }
32 4
        }
33
34
        /**
35
         * @todo Implement check
36
         */
37 4
        return $compiler->compile($expr->name);
38
    }
39
}
40