TagFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 23
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A getTag() 0 21 4
1
<?php
2
/**
3
 * {CLASS SUMMARY}
4
 *
5
 * Date: 7/27/18
6
 * Time: 10:53 PM
7
 * @author Michael Munger <[email protected]>
8
 */
9
10
namespace HPHIO\Farret;
11
12
13
class TagFactory extends AbstractTagFactory
14
{
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 = [];
0 ignored issues
show
Unused Code introduced by
The assignment to $matches is dead and can be removed.
Loading history...
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
}