Completed
Pull Request — master (#194)
by Enrico
07:43
created

SwitchSt   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 22
ccs 8
cts 9
cp 0.8889
rs 10
wmc 3
lcom 0
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A compile() 0 12 3
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 SwitchSt extends AbstractCompiler
12
{
13
    protected $name = '\PhpParser\Node\Stmt\Switch_';
14
15
    /**
16
     * @param \PhpParser\Node\Stmt\Switch_ $stmt
17
     * @param Context $context
18
     * @return CompiledExpression
19
     */
20 3
    public function compile($stmt, Context $context)
21
    {
22 3
        $context->getExpressionCompiler()->compile($stmt->cond);
23
24 3
        if (count($stmt->cases) > 0) {
25 3
            foreach ($stmt->cases as $case) {
26 3
                \PHPSA\nodeVisitorFactory($case, $context);
27 3
            }
28 3
        } else {
29
            $context->notice('not-implemented-body', 'Missing body', $stmt);
30
        }
31 3
    }
32
}
33