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

RegularComment   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 76.47%

Importance

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

6 Methods

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