Passed
Push — main ( 28fe2f...804823 )
by mikhail
03:26
created

RegularComment   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 47.06%

Importance

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

6 Methods

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