Total Complexity | 8 |
Total Lines | 68 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
9 | abstract class Tag |
||
10 | { |
||
11 | /** |
||
12 | * @var |
||
13 | */ |
||
14 | protected static $content; |
||
15 | |||
16 | /** |
||
17 | * @var |
||
18 | */ |
||
19 | protected static $config; |
||
20 | |||
21 | protected $match = []; |
||
22 | |||
23 | 22 | /** |
|
24 | * Tag constructor. |
||
25 | 22 | */ |
|
26 | 22 | public function __construct(string $pattern) |
|
27 | { |
||
28 | if (preg_match_all($pattern, self::getContent(), $matches, PREG_SET_ORDER)) { |
||
29 | $count = count($matches); |
||
30 | for ($i = 0; $i < $count; $i++) { |
||
31 | $this->match = $matches[$i]; |
||
32 | $this->replace($this->handle()); |
||
33 | } |
||
34 | } |
||
35 | } |
||
36 | 22 | ||
37 | /** |
||
38 | 22 | * @return mixed |
|
39 | 22 | */ |
|
40 | abstract public function handle(): string; |
||
41 | |||
42 | protected function replace(string $replace): void |
||
45 | } |
||
46 | 22 | ||
47 | /** |
||
48 | * @param string $content |
||
49 | */ |
||
50 | public static function setContent(string $content): void |
||
51 | { |
||
52 | 6 | self::$content = $content; |
|
53 | } |
||
54 | 6 | ||
55 | 6 | /** |
|
56 | * @return string |
||
57 | */ |
||
58 | public static function getContent(): string |
||
59 | { |
||
60 | 2 | return self::$content; |
|
61 | } |
||
62 | 2 | ||
63 | /** |
||
64 | * @param array $config |
||
65 | */ |
||
66 | public static function setConfig(array $config): void |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * @return array |
||
73 | */ |
||
74 | public static function getConfig(): array |
||
79 |