Total Complexity | 4 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Coverage | 46.88% |
Changes | 0 |
1 | <?php |
||
5 | class Condition extends Tag |
||
6 | { |
||
7 | 2 | public function __construct() |
|
8 | { |
||
9 | 2 | $this->elseif(); |
|
10 | 2 | $this->else(); |
|
11 | 2 | $this->if(); |
|
12 | 2 | } |
|
13 | |||
14 | 2 | private function if() |
|
15 | { |
||
16 | 2 | $search = "/{(\s?)+if(\s?)+([\$\w\.]+)(\s?)+([<>!=]+)(\s?)+([\$\w\d\.\"' ]+)(\s?)+}(.*?){(\s?)+\/if(\s?)+}/is"; |
|
17 | |||
18 | Tag::match($search, function($left, $op, $right, $content = "") { |
||
19 | |||
20 | $left = str_replace('.', '->', $left); |
||
21 | $right = str_replace('.', '->', $right); |
||
22 | |||
23 | $res = "<?php if ($left $op $right) { ?>"; |
||
24 | $res .= $content; |
||
25 | $res .= "<?php } ?>"; |
||
26 | |||
27 | Tag::replace($res); |
||
28 | |||
29 | $this->if(); |
||
30 | 2 | }); |
|
31 | 2 | } |
|
32 | |||
33 | 2 | private function else() |
|
34 | { |
||
35 | 2 | $search = "/{(\s?)+else(\s?)+}(.*?)/is"; |
|
36 | |||
37 | Tag::match($search, function($content = "") { |
||
38 | |||
39 | $res = "<?php } else { ?>"; |
||
40 | $res .= $content; |
||
41 | |||
42 | Tag::replace($res); |
||
43 | |||
44 | $this->else(); |
||
45 | 2 | }); |
|
46 | 2 | } |
|
47 | |||
48 | 2 | private function elseif() |
|
63 | 2 | }); |
|
64 | 2 | } |
|
65 | } |
||
66 |