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

Inheritance   A

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 = \EdsonOnildo\Tpl\Content::getContent($layoutName);
0 ignored issues
show
Bug introduced by
The type EdsonOnildo\Tpl\Content was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
43
          
44
            Tag::replace($content);
45
            
46
            $this->__construct();
47
        });
48
    }
49
}
50