Completed
Pull Request — master (#296)
by algo13
03:47
created

ContinueSt   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 58.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 26
ccs 7
cts 12
cp 0.5833
rs 10
c 1
b 0
f 0
wmc 4
lcom 0
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A compile() 0 16 4
1
<?php
2
3
namespace PHPSA\Compiler\Statement;
4
5
use PhpParser\Node\Scalar\LNumber;
6
use PHPSA\CompiledExpression;
7
use PHPSA\Context;
8
9
class ContinueSt extends AbstractCompiler
10
{
11
    protected $name = '\PhpParser\Node\Stmt\Continue_';
12
13
    /**
14
     * @param \PhpParser\Node\Stmt\Continue_ $stmt
15
     * @param Context $context
16
     * @return CompiledExpression
17
     */
18 1
    public function compile($stmt, Context $context)
19
    {
20 1
        $compiler = $context->getExpressionCompiler();
21
22 1
        if ($stmt->num !== null) {
23 1
            $compiled = $compiler->compile($stmt->num);
24
25 1
            if (!($stmt->num instanceof LNumber) || $compiled->getValue() == 0) {
26
                $context->notice(
27
                    'language_error',
28
                    'Continue only supports positive integers.',
29
                    $stmt
30
                );
31
            }
32 1
        }
33 1
    }
34
}
35