Completed
Push — master ( a0ab4a...efa69f )
by Дмитрий
03:02
created

functions.php ➔ nodeVisitorFactory()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6
Metric Value
cc 2
eloc 6
nc 2
nop 2
dl 0
loc 10
ccs 0
cts 5
cp 0
crap 6
rs 9.4285
1
<?php
2
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA;
7
8
use PHPSA\Compiler\Expression;
9
use PHPSA\Compiler\Statement;
10
use PhpParser\Node;
11
12
/**
13
 * @param $stmt
14
 * @return Expression|Statement
15
 */
16
function nodeVisitorFactory($stmt, Context $context)
17
{
18
    if ($stmt instanceof Node\Stmt) {
19
        $visitor = new Statement($stmt, $context);
20
        return $visitor;
21
    }
22
23
    $visitor = new Expression($context);
24
    return $visitor->compile($stmt);
25
}
26