| Total Complexity | 9 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | final class ComToLoc |
||
| 16 | { |
||
| 17 | private bool $exceedThreshold = false; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param array<string, float> $thresholds |
||
| 21 | */ |
||
| 22 | 5 | public function __construct(private readonly array $thresholds) {} |
|
| 23 | |||
| 24 | /** |
||
| 25 | * @param CommentStatisticsDTO[] $commentStatistics |
||
| 26 | */ |
||
| 27 | 5 | public function prepareComToLoc(array $commentStatistics, int $linesOfCode): ComToLocDTO |
|
| 28 | { |
||
| 29 | 5 | $ratio = $this->getRatio($commentStatistics, $linesOfCode); |
|
| 30 | |||
| 31 | 5 | return new ComToLocDTO( |
|
| 32 | 5 | $ratio, |
|
| 33 | 5 | $this->getColorForRatio($ratio), |
|
| 34 | 5 | ); |
|
| 35 | } |
||
| 36 | |||
| 37 | 1 | public function hasExceededThreshold(): bool |
|
| 38 | { |
||
| 39 | 1 | return $this->exceedThreshold; |
|
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @param CommentStatisticsDTO[] $commentStatistics |
||
| 44 | */ |
||
| 45 | 5 | private function getRatio(array $commentStatistics, int $linesOfCode): float |
|
| 46 | { |
||
| 47 | 5 | if ($linesOfCode === 0) { |
|
| 48 | 1 | return 0; |
|
| 49 | } |
||
| 50 | |||
| 51 | 4 | $totalComments = 0; |
|
| 52 | |||
| 53 | 4 | foreach ($commentStatistics as $stat) { |
|
| 54 | 4 | $totalComments += $stat->lines; |
|
| 55 | } |
||
| 56 | |||
| 57 | 4 | return round($totalComments / $linesOfCode, 2); |
|
| 58 | } |
||
| 59 | |||
| 60 | 5 | private function getColorForRatio(float $ratio): string |
|
| 71 | } |
||
| 72 | } |
||
| 73 |
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