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

RegularComment::getStatColor()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 10
ccs 0
cts 7
cp 0
crap 12
rs 10
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