Passed
Push — main ( fcc13f...628042 )
by mikhail
02:55
created

FixMeComment   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 47.06%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 12
c 1
b 0
f 0
dl 0
loc 37
ccs 8
cts 17
cp 0.4706
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getColor() 0 3 1
A getStatColor() 0 10 3
A getAttitude() 0 3 1
A getPattern() 0 3 1
A getName() 0 3 1
A getWeight() 0 3 1
1
<?php
2
3
namespace SavinMikhail\CommentsDensity\Comments;
4
5
class FixMeComment extends Comment implements CommentTypeInterface
6
{
7 8
    public function getPattern(): string
8
    {
9 8
        return '/(?:\/\/|#|\/\*|\*|<!--).*?\bfixme\b.*/i';
10
    }
11
12
    public function getColor(): string
13
    {
14
        return 'yellow';
15
    }
16
17
    public function getStatColor(int $count, array $thresholds): string
18
    {
19
        if (! isset($thresholds[$this->getName()])) {
20
            return 'white';
21
        }
22
        if ($count <= $thresholds[$this->getName()]) {
23
            return 'green';
24
        }
25
        $this->exceedThreshold = true;
26
        return 'red';
27
    }
28
29 1
    public function getWeight(): float
30
    {
31 1
        return -0.3;
32
    }
33
34 1
    public function getAttitude(): string
35
    {
36 1
        return 'unwanted';
37
    }
38
39 2
    public function getName(): string
40
    {
41 2
        return 'fixme';
42
    }
43
}
44