Passed
Push — master ( 3849b2...6d2bbe )
by Edson
01:17
created

Block   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 28
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A default() 0 7 1
A __construct() 0 4 1
A content() 0 9 2
1
<?php
2
3
namespace Bonfim\Tpl\Tag;
4
5
class Block extends Tag
6
{
7
    public function __construct()
8
    {
9
        $this->content();
10
        $this->default();
11
    }
12
13
    private function content()
14
    {
15
        foreach (Tag::$blocks as $blockName => $blockContent) {
16
17
            $search = "/@(\s?)+block(\s?)+{$blockName}.*?@(\s?)+endblock/is";
18
19
            Tag::match($search, function() use ($blockContent) {
20
                Tag::replace($blockContent);
21
                $this->content();
22
            });
23
        }
24
    }
25
26
    private function default()
27
    {
28
        $search = "/@(\s?)+block(\s?)+[\w]+(.*?)@(\s?)+endblock/is";
29
30
        Tag::match($search, function($content = '') {
31
            Tag::replace($content);
32
            $this->default();
33
        });
34
    }
35
}
36