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

ResolveExpressionTrait::resolveFunctionName()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

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