Completed
Push — master ( 9b2dbf...68bd43 )
by Дмитрий
02:56
created

ResolveExpressionTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 24
ccs 0
cts 9
cp 0
rs 10
wmc 3
lcom 0
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveFunctionName() 0 15 3
1
<?php
2
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA\Analyzer\Helper;
7
8
use PhpParser\Node\Expr\FuncCall;
9
use PHPSA\Context;
10
11
trait ResolveExpressionTrait
12
{
13
    /**
14
     * @param FuncCall $funcCall
15
     * @param Context $context
16
     * @return string|bool
17
     * @throws \PHPSA\Exception\RuntimeException
18
     */
19
    public function resolveFunctionName(FuncCall $funcCall, Context $context)
20
    {
21
        $funcNameCompiledExpression = $context->getExpressionCompiler()->compile($funcCall->name);
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $funcNameCompiledExpression exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
22
23
        if ($funcNameCompiledExpression->isString() && $funcNameCompiledExpression->isCorrectValue()) {
24
            return $funcNameCompiledExpression->getValue();
25
        } else {
26
            $context->debug(
27
                'Unexpected function name type ' . $funcNameCompiledExpression->getType(),
28
                $funcCall->name
29
            );
30
        }
31
32
        return false;
33
    }
34
}
35