Completed
Pull Request — master (#38)
by Pádraic
02:50
created

OperationExtension::extend()   B

Complexity

Conditions 8
Paths 8

Size

Total Lines 21
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 7.1428
c 0
b 0
f 0
cc 8
eloc 18
nc 8
nop 1
1
<?php
2
3
namespace PHPMND\Extension;
4
5
use PhpParser\Node;
6
use PhpParser\Node\Expr\BinaryOp\Div;
7
use PhpParser\Node\Expr\BinaryOp\Minus;
8
use PhpParser\Node\Expr\BinaryOp\Mod;
9
use PhpParser\Node\Expr\BinaryOp\Mul;
10
use PhpParser\Node\Expr\BinaryOp\Plus;
11
use PhpParser\Node\Expr\BinaryOp\Pow;
12
use PhpParser\Node\Expr\BinaryOp\ShiftLeft;
13
use PhpParser\Node\Expr\BinaryOp\ShiftRight;
14
15
/**
16
 * Class OperationExtension
17
 *
18
 * @package PHPMND\Extension
19
 */
20
class OperationExtension implements Extension
21
{
22
    /**
23
     * @inheritdoc
24
     */
25
    public function extend(Node $node)
26
    {
27
        $parentNode = $node->getAttribute('parent');
28
29
        return
30
            $parentNode instanceof Mul
31
            ||
32
            $parentNode instanceof Div
33
            ||
34
            $parentNode instanceof Plus
35
            ||
36
            $parentNode instanceof Minus
37
            ||
38
            $parentNode instanceof Mod
39
            ||
40
            $parentNode instanceof ShiftLeft
41
            ||
42
            $parentNode instanceof ShiftRight
43
            ||
44
            $parentNode instanceof Pow;
45
    }
46
}
47