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

ArgumentExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A extend() 0 4 1
A ignoreFunc() 0 12 3
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