Completed
Push — master ( 78e4d9...0bf797 )
by Povilas
8s
created

ArgumentExtension::extend()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Povils\PHPMND\Extension;
4
5
use PhpParser\Node;
6
use PhpParser\Node\Arg;
7
use PhpParser\Node\Expr\FuncCall;
8
use PhpParser\Node\Name;
9
10
/**
11
 * Class ArgumentExtension
12
 *
13
 * @package Povils\PHPMND\Extension
14
 */
15
class ArgumentExtension implements FunctionAwareExtension
16
{
17
    /**
18
     * @inheritdoc
19
     */
20
    public function extend(Node $node)
21
    {
22
        return $node->getAttribute('parent') instanceof Arg;
23
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28
    public function ignoreFunc(Node $node, array $ignoreFuncs)
29
    {
30
        /** @var FuncCall $funcCallNode */
31
        $funcCallNode = $node->getAttribute('parent')->getAttribute('parent');
32
33
        return
34
            $funcCallNode instanceof FuncCall
35
            &&
36
            $funcCallNode->name instanceof Name
37
            &&
38
            in_array($funcCallNode->name->getLast(), $ignoreFuncs, true);
39
    }
40
}
41