Passed
Push — master ( 973a91...34c593 )
by Edson
01:12
created

RepeatTag::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sketch\Tpl;
4
5
class RepeatTag extends Tag
6
{
7
    public function __construct()
8
    {
9
        parent::__construct('/{(\s?)+repeat (\s?)+([\d]+)(\s?)+}(.*?){(\s?)+\/repeat(\s?)+}/is');
10
    }
11
12
    public function handle(): string
13
    {
14
        $replace  = "<?php for (\$i = 0; \$i < {$this->match[3]}; \$i++) { ?>";
15
        $replace .= $this->match[5];
16
        $replace .= "<?php } ?>";
17
18
        return $replace;
19
    }
20
}
21