Completed
Pull Request — master (#8)
by Povilas
03:23 queued 01:26
created

ArgumentExtension::ignoreFunc()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 3
eloc 8
nc 3
nop 2
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