Completed
Pull Request — master (#130)
by Kévin
03:10
created

CatchSt::compile()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.0987

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 2
b 0
f 0
nc 4
nop 2
dl 0
loc 12
ccs 7
cts 9
cp 0.7778
crap 3.0987
rs 9.4285
1
<?php
2
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA\Compiler\Statement;
7
8
use PHPSA\CompiledExpression;
9
use PHPSA\Context;
10
use PHPSA\Variable;
11
12
class CatchSt extends AbstractCompiler
13
{
14
    protected $name = '\PhpParser\Node\Stmt\Catch_';
15
16
    /**
17
     * @param \PhpParser\Node\Stmt\Catch_ $statement
18
     * @param Context $context
19
     */
20 1
    public function compile($statement, Context $context)
21
    {
22 1
        $context->addVariable(new Variable($statement->var, null, CompiledExpression::OBJECT));
23
24 1
        if (count($statement->stmts) === 0) {
25
            $context->notice('not-implemented-body', 'Missing body', $statement);
26
        }
27
28 1
        foreach ($statement->stmts as $stmt) {
29 1
            \PHPSA\nodeVisitorFactory($stmt, $context);
30 1
        }
31 1
    }
32
}
33