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

RegularComment::getPattern()   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 2
Bugs 1 Features 0
Metric Value
eloc 1
c 2
b 1
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 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