Completed
Pull Request — master (#149)
by Enrico
04:04
created

WhileSt   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
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 WhileSt extends AbstractCompiler
12
{
13
    protected $name = '\PhpParser\Node\Stmt\While_';
14
15
    /**
16
     * @param \PhpParser\Node\Stmt\While_ $stmt
17
     * @param Context $context
18
     * @return CompiledExpression
19
     */
20 2
    public function compile($stmt, Context $context)
21
    {
22 2
        $context->getExpressionCompiler()->compile($stmt->cond);
23
24 2
        if (count($stmt->stmts) > 0) {
25 1
            foreach ($stmt->stmts as $statement) {
26 1
                \PHPSA\nodeVisitorFactory($statement, $context);
27 1
            }
28 1
        } else {
29 1
            $context->notice('not-implemented-body', 'Missing body', $stmt);
30
        }
31 2
    }
32
}
33