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

RegularComment::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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