Passed
Push — master ( 9e2b32...3849b2 )
by Edson
02:50
created

Condition::config()   C

Complexity

Conditions 13
Paths 4

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 182

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
ccs 0
cts 8
cp 0
rs 6.6166
c 0
b 0
f 0
cc 13
nc 4
nop 2
crap 182

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace EdsonOnildo\Tpl\Tag;
4
5
class Condition extends Tag
6
{
7
    public function __construct()
8
    {
9
        $this->if();
10
        $this->elseif();
11
        $this->else();
12
        $this->endif();
13
    }
14
15
    public function if()
16
    {
17
        self::match('/@\s*if\s*\((.*?)\)/', function($cond) {
0 ignored issues
show
Bug Best Practice introduced by
The method EdsonOnildo\Tpl\Tag\Tag::match() is not static, but was called statically. ( Ignorable by Annotation )

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

17
        self::/** @scrutinizer ignore-call */ 
18
              match('/@\s*if\s*\((.*?)\)/', function($cond) {
Loading history...
18
19
            self::replace("<?php if ($cond) : ?>");
0 ignored issues
show
Bug Best Practice introduced by
The method EdsonOnildo\Tpl\Tag\Tag::replace() is not static, but was called statically. ( Ignorable by Annotation )

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

19
            self::/** @scrutinizer ignore-call */ 
20
                  replace("<?php if ($cond) : ?>");
Loading history...
20
        });
21
    }
22
23
    public function elseif() {
24
        self::match('/@\s*elseif\s*\((.*?)\)/', function($cond) {
0 ignored issues
show
Bug Best Practice introduced by
The method EdsonOnildo\Tpl\Tag\Tag::match() is not static, but was called statically. ( Ignorable by Annotation )

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

24
        self::/** @scrutinizer ignore-call */ 
25
              match('/@\s*elseif\s*\((.*?)\)/', function($cond) {
Loading history...
25
26
            self::replace("<?php elseif ($cond) : ?>");
0 ignored issues
show
Bug Best Practice introduced by
The method EdsonOnildo\Tpl\Tag\Tag::replace() is not static, but was called statically. ( Ignorable by Annotation )

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

26
            self::/** @scrutinizer ignore-call */ 
27
                  replace("<?php elseif ($cond) : ?>");
Loading history...
27
        });
28
    }
29
30
    public function else()
31
    {
32
        self::match('/@\s*else/', function () {
0 ignored issues
show
Bug Best Practice introduced by
The method EdsonOnildo\Tpl\Tag\Tag::match() is not static, but was called statically. ( Ignorable by Annotation )

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

32
        self::/** @scrutinizer ignore-call */ 
33
              match('/@\s*else/', function () {
Loading history...
33
34
            self::replace("<?php else : ?>");
0 ignored issues
show
Bug Best Practice introduced by
The method EdsonOnildo\Tpl\Tag\Tag::replace() is not static, but was called statically. ( Ignorable by Annotation )

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

34
            self::/** @scrutinizer ignore-call */ 
35
                  replace("<?php else : ?>");
Loading history...
35
        });
36
    }
37
38
    public function endif()
39
    {
40
        $regex = '/@\s*\/if/';
41
42
        self::match($regex, function () {
0 ignored issues
show
Bug Best Practice introduced by
The method EdsonOnildo\Tpl\Tag\Tag::match() is not static, but was called statically. ( Ignorable by Annotation )

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

42
        self::/** @scrutinizer ignore-call */ 
43
              match($regex, function () {
Loading history...
43
44
            self::replace("<?php endif ?>");
0 ignored issues
show
Bug Best Practice introduced by
The method EdsonOnildo\Tpl\Tag\Tag::replace() is not static, but was called statically. ( Ignorable by Annotation )

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

44
            self::/** @scrutinizer ignore-call */ 
45
                  replace("<?php endif ?>");
Loading history...
45
        });
46
    }
47
}
48