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

Inheritance::getParentContent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 13
ccs 0
cts 8
cp 0
crap 2
rs 10
c 0
b 0
f 0
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