Completed
Branch master (e379bd)
by Pierre-Henry
33:06
created

Smarty_Internal_Compile_Continue::compile()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 3
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Smarty Internal Plugin Compile Continue
4
 * Compiles the {continue} tag
5
 *
6
 * @package    Smarty
7
 * @subpackage Compiler
8
 * @author     Uwe Tews
9
 */
10
11
/**
12
 * Smarty Internal Plugin Compile Continue Class
13
 *
14
 * @package    Smarty
15
 * @subpackage Compiler
16
 */
17
class Smarty_Internal_Compile_Continue extends Smarty_Internal_Compile_Break
18
{
19
20
    /**
21
     * Compiles code for the {continue} tag
22
     *
23
     * @param  array                                $args      array with attributes from parser
24
     * @param \Smarty_Internal_TemplateCompilerBase $compiler  compiler object
25
     * @param  array                                $parameter array with compilation parameter
26
     *
27
     * @return string compiled code
28
     * @throws \SmartyCompilerException
29
     */
30
    public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
31
    {
32
        list($levels, $foreachLevels) = $this->checkLevels($args, $compiler, 'continue');
33
        $output = "<?php\n";
34
        if ($foreachLevels > 1) {
35
            /* @var Smarty_Internal_Compile_Foreach $foreachCompiler */
36
            $foreachCompiler = $compiler->getTagCompiler('foreach');
37
            $output .= $foreachCompiler->compileRestore($foreachLevels - 1);
38
        }
39
        $output .= "continue {$levels};?>";
40
        return $output;
41
    }
42
}
43