TemplateHook   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 94.44%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 33
ccs 17
cts 18
cp 0.9444
rs 10
c 0
b 0
f 0
wmc 8

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getTag() 0 2 1
A getLabel() 0 6 2
A setup() 0 2 1
A fart() 0 10 3
A getReplacement() 0 3 1
1
<?php
2
/**
3
 * {CLASS SUMMARY}
4
 *
5
 * Date: 7/27/18
6
 * Time: 11:26 PM
7
 * @author Michael Munger <[email protected]>
8
 */
9
10
namespace HPHIO\Farret;
11
12
13
class TemplateHook extends AbstractTag
14
{
15 6
    public function getLabel()
16
    {
17 6
        $matches = [];
18 6
        $result = (preg_match_all($this->pattern, $this->tag,$matches, PREG_SET_ORDER) !== false);
19
20 6
        return ($result ? $matches[0][1] : false);
21
    }
22
23 13
    public function setup() {
24 13
        $this->type = AbstractTag::HOOK;
0 ignored issues
show
Bug Best Practice introduced by
The property type does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
25 13
    }
26
27 2
    public function fart($dictionary) {
28 2
        $label = $this->getLabel();
29 2
        foreach($dictionary as $find => $replace) {
30 1
            if(strcmp($find,$label) === 0) {
0 ignored issues
show
Bug introduced by
It seems like $label can also be of type false; however, parameter $str2 of strcmp() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

30
            if(strcmp($find,/** @scrutinizer ignore-type */ $label) === 0) {
Loading history...
31
                $this->replacement = $replace;
32 1
                return true;
33
            }
34
        }
35
36 2
        return false;
37
    }
38
39 1
    public function getTag() {
40 1
        return $this->tag;
41
    }
42
43 2
    public function getReplacement()
44
    {
45 2
        return $this->replacement;
46
    }
47
48
}