Completed
Push — master ( 069124...27e495 )
by Edson
02:00
created

Block::default()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.125

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
ccs 2
cts 4
cp 0.5
crap 1.125
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sketch\Tpl\Tag;
4
5
class Block extends Tag
6
{
7 2
    public function __construct()
8
    {
9 2
        $this->content();
10 2
        $this->default();
11 2
    }
12
13 2
    private function content()
14
    {
15 2
        foreach (Tag::$blocks as $blockName => $blockContent) {
16
17
            $search = "/{(\s?)+{$blockName}(\s?)+}.*?{(\s?)+\/{$blockName}(\s?)+}/is";
18
19
            Tag::match($search, function() use ($blockContent) {
20
                Tag::replace($blockContent);
21
                $this->content();
22
            });
23
        }
24 2
    }
25
26 2
    private function default()
27
    {
28 2
        $search = "/{(\s?)+[\w]+(\s?)+}(.*?){(\s?+)\/[\w]+(\s?)+}/is";
29
30
        Tag::match($search, function($content = '') {
31
            Tag::replace($content);
32
            $this->default();
33 2
        });
34 2
    }
35
}
36