Inheritance   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 42
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getBlockContent() 0 17 2
A getParentContent() 0 13 1
A __construct() 0 4 1
1
<?php
2
3
namespace Bonfim\Tpl\Tag;
4
5
class Inheritance extends Tag
6
{
7
    public function __construct()
8
    {
9
        $this->getBlockContent();
10
        $this->getParentContent();
11
    }
12
13
    private function getBlockContent(): void
14
    {
15
        $search = "/@(\s?)+extends.*@(\s?)+block(\s?)+([\w]+)/is";
16
17
        Tag::match($search, function($blockName) {
18
19
            $search = "/@(\s?)+block(\s?)+$blockName(.*?)@(\s?)+endblock/is";
20
21
            Tag::match($search, function($content) use ($blockName) {
22
23
                if (!array_key_exists($blockName, Tag::$blocks)) {
24
                    Tag::$blocks[$blockName] = $content;
25
                }
26
27
                Tag::replace('');
28
29
                $this->getBlockContent();
30
            });
31
        });
32
    }
33
34
    private function getParentContent(): void
35
    {
36
        $search = "/@(\s?)+extends ([\w\.]+)/is";
37
38
        Tag::match($search, function($layoutName) {
39
40
            $layoutName = str_replace('.', '/', $layoutName);
41
42
            $content = \Bonfim\Tpl\Content::getContent($layoutName);
43
          
44
            Tag::replace($content);
45
            
46
            $this->__construct();
47
        });
48
    }
49
}
50