Conditions | 4 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
15 | 64 | public function getTag($tag) { |
|
16 | |||
17 | 64 | $templatePattern = '/^(?:{{)\s{0,}([A-Z]+)\s{0,}(?:}})$/m'; |
|
18 | 64 | $templateHookPattern = '/(?:{%)\s{0,}([A-Z]+)\s{0,}(?:%})/'; |
|
19 | 64 | $templateHookWithArgsPattern = '/(?:{%)\s{0,}([A-Z]+)\|([a-zA-Z0-9-{}|]+)\s{0,}(?:%})/'; |
|
20 | |||
21 | 64 | $matches = []; |
|
|
|||
22 | |||
23 | 64 | if(preg_match($templatePattern, $tag) === 1 ) { |
|
24 | 23 | return new TemplateTag($templatePattern, $tag); |
|
25 | } |
||
26 | |||
27 | 45 | if(preg_match($templateHookPattern, $tag) === 1 ) { |
|
28 | 13 | return new TemplateHook($templateHookPattern, $tag); |
|
29 | } |
||
30 | |||
31 | 34 | if(preg_match($templateHookWithArgsPattern, $tag) === 1 ) { |
|
32 | 26 | return new TemplateHookWithArgs($templateHookWithArgsPattern, $tag); |
|
33 | } |
||
34 | |||
35 | 13 | return false; |
|
36 | } |
||
37 | } |