Total Complexity | 9 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
11 | final class ComToLoc |
||
12 | { |
||
13 | private bool $exceedThreshold = false; |
||
14 | |||
15 | /** |
||
16 | * @param array<string, float> $thresholds |
||
17 | */ |
||
18 | public function __construct(private readonly array $thresholds) {} |
||
19 | |||
20 | /** |
||
21 | * @param CommentStatisticsDTO[] $commentStatistics |
||
22 | */ |
||
23 | public function prepareComToLoc(array $commentStatistics, int $linesOfCode): ComToLocDTO |
||
24 | { |
||
25 | $ratio = $this->getRatio($commentStatistics, $linesOfCode); |
||
26 | |||
27 | return new ComToLocDTO( |
||
28 | $ratio, |
||
29 | $this->getColorForRatio($ratio), |
||
30 | ); |
||
31 | } |
||
32 | |||
33 | public function hasExceededThreshold(): bool |
||
34 | { |
||
35 | return $this->exceedThreshold; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @param CommentStatisticsDTO[] $commentStatistics |
||
40 | */ |
||
41 | private function getRatio(array $commentStatistics, int $linesOfCode): float |
||
42 | { |
||
43 | if ($linesOfCode === 0) { |
||
44 | return 0; |
||
45 | } |
||
46 | |||
47 | $totalComments = 0; |
||
48 | |||
49 | foreach ($commentStatistics as $stat) { |
||
50 | $totalComments += $stat->lines; |
||
51 | } |
||
52 | |||
53 | return round($totalComments / $linesOfCode, 2); |
||
54 | } |
||
55 | |||
56 | private function getColorForRatio(float $ratio): string |
||
67 | } |
||
68 | } |
||
69 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths