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

RepeatTag   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 7 1
A __construct() 0 3 1
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