Completed
Push — master ( 7e1c48...853d12 )
by Дмитрий
03:20
created

SwitchSt   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 93.75%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 30
ccs 15
cts 16
cp 0.9375
rs 10
wmc 6
lcom 0
cbo 5

1 Method

Rating   Name   Duplication   Size   Complexity  
B compile() 0 20 6
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 1
    public function compile($stmt, Context $context)
21
    {
22 1
        $context->getExpressionCompiler()->compile($stmt->cond);
23
24 1
        if (count($stmt->cases)) {
25 1
            foreach ($stmt->cases as $case) {
26 1
                if ($case->cond) {
27 1
                    $context->getExpressionCompiler()->compile($case->cond);
28 1
                }
29
30 1
                if (count($case->stmts)) {
31 1
                    foreach ($case->stmts as $caseStatements) {
32 1
                        \PHPSA\nodeVisitorFactory($caseStatements, $context);
33 1
                    }
34 1
                }
35 1
            }
36 1
        } else {
37
            $context->notice('switch.empty', 'Switch block is empty, lol', $stmt);
38
        }
39 1
    }
40
}
41