Total Complexity | 12 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Coverage | 30.76% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | abstract class Comment implements Stringable, CommentTypeInterface |
||
10 | { |
||
11 | protected bool $exceedThreshold = false; |
||
12 | |||
13 | public function hasExceededThreshold(): bool |
||
14 | { |
||
15 | return $this->exceedThreshold; |
||
16 | } |
||
17 | |||
18 | 9 | public function matchesPattern(string $token): bool |
|
19 | { |
||
20 | 9 | return (bool) preg_match($this->getPattern(), $token); |
|
21 | } |
||
22 | |||
23 | public function __toString(): string |
||
26 | } |
||
27 | |||
28 | public function getStatColor(int $count, array $thresholds): string |
||
29 | { |
||
30 | if (!isset($thresholds[$this->getName()])) { |
||
31 | return 'white'; |
||
32 | } |
||
33 | if ($this->isWithinThreshold($count, $thresholds)) { |
||
34 | return 'green'; |
||
35 | } |
||
36 | $this->exceedThreshold = true; |
||
37 | return 'red'; |
||
38 | } |
||
39 | |||
40 | protected function isWithinThreshold(int $count, array $thresholds): bool |
||
41 | { |
||
42 | $comparisonValue = $thresholds[static::NAME]; |
||
|
|||
43 | |||
44 | if (static::COMPARISON_TYPE === '>=') { |
||
45 | return $count >= $comparisonValue; |
||
46 | } |
||
47 | |||
48 | return $count <= $comparisonValue; |
||
49 | } |
||
50 | |||
51 | 9 | public function getPattern(): string |
|
52 | { |
||
53 | 9 | return static::PATTERN; |
|
54 | } |
||
55 | |||
56 | public function getColor(): string |
||
59 | } |
||
60 | |||
61 | 1 | public function getWeight(): float |
|
62 | { |
||
63 | 1 | return static::WEIGHT; |
|
64 | } |
||
65 | |||
66 | 1 | public function getName(): string |
|
69 | } |
||
70 | } |
||
71 |