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

Tag   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 46
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
A match() 0 10 3
A getContent() 0 3 1
A setContent() 0 3 1
A replace() 0 3 1
A setConfig() 0 3 1
A getConfig() 0 3 1
1
<?php
2
3
namespace Sketch\Tpl\Tag;
4
5
abstract class Tag
6
{
7
    protected static $blocks = [];
8
    protected static $config;
9
    
10
    private static $content;
11
12
    private $search;
13
14 2
    protected function replace(string $replace): void
15
    {
16 2
        self::$content = str_replace($this->search, $replace, self::$content);
17 2
    }
18
19 2
    protected function match($pattern, $callback): void
20
    {
21 2
        if (preg_match_all($pattern, self::getContent(), $matches, PREG_SET_ORDER)) {
22 2
            foreach ($matches as $match) {
23
                
24 2
                $this->search = $match[0];
25
26 2
                unset($match[0]);
27
28 2
                call_user_func_array($callback, array_filter($match));
29
            }
30
        }
31 2
    }
32
33 2
    public static function setContent(string $content): void
34
    {
35 2
        self::$content = $content;
36 2
    }
37
38 2
    public static function getContent(): string
39
    {
40 2
        return self::$content;
41
    }
42
43 2
    public static function setConfig(array $config): void
44
    {
45 2
        self::$config = $config;
46 2
    }
47
48 2
    public static function getConfig(): array
49
    {
50 2
        return self::$config;
51
    }
52
}
53