Completed
Pull Request — master (#272)
by Enrico
10:32 queued 01:21
created

TryCatchSt::compile()   B

Complexity

Conditions 6
Paths 16

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 8.304

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 6
eloc 9
c 1
b 0
f 0
nc 16
nop 2
dl 0
loc 18
ccs 9
cts 15
cp 0.6
crap 8.304
rs 8.8571
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
11
class TryCatchSt extends AbstractCompiler
12
{
13
    protected $name = '\PhpParser\Node\Stmt\TryCatch';
14
15
    /**
16
     * @param \PhpParser\Node\Stmt\TryCatch $statement
17
     * @param Context $context
18
     * @return CompiledExpression
19
     */
20 2
    public function compile($statement, Context $context)
21
    {
22 2
        foreach ($statement->stmts as $stmt) {
23 2
            \PHPSA\nodeVisitorFactory($stmt, $context);
24 2
        }
25
26 2
        foreach ($statement->catches as $stmt) {
27 2
            \PHPSA\nodeVisitorFactory($stmt, $context);
28 2
        }
29
30 2
        if ($statement->finallyStmts !== null) {
31
            if (count($statement->finallyStmts) > 0) {
32
                foreach ($statement->finallyStmts as $stmt) {
33
                    \PHPSA\nodeVisitorFactory($stmt, $context);
34
                }
35
            }
36
        }
37 2
    }
38
}
39