savinmikhail /
Comments-Density
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace SavinMikhail\CommentsDensity\AnalyzeComments\Metrics; |
||
| 6 | |||
| 7 | use SavinMikhail\CommentsDensity\AnalyzeComments\Analyzer\DTO\Output\CdsDTO; |
||
| 8 | use SavinMikhail\CommentsDensity\AnalyzeComments\Analyzer\DTO\Output\CommentStatisticsDTO; |
||
| 9 | use SavinMikhail\CommentsDensity\AnalyzeComments\Analyzer\DTO\Output\ComToLocDTO; |
||
| 10 | use SavinMikhail\CommentsDensity\AnalyzeComments\Analyzer\DTO\Output\PerformanceMetricsDTO; |
||
| 11 | |||
| 12 | final readonly class MetricsFacade |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 13 | { |
||
| 14 | public function __construct( |
||
| 15 | private CDS $cds, |
||
| 16 | private ComToLoc $comToLoc, |
||
| 17 | private ResourceUtilization $performanceMonitor, |
||
| 18 | ) {} |
||
| 19 | |||
| 20 | public function startPerformanceMonitoring(): void |
||
| 21 | { |
||
| 22 | $this->performanceMonitor->start(); |
||
| 23 | } |
||
| 24 | |||
| 25 | public function stopPerformanceMonitoring(): void |
||
| 26 | { |
||
| 27 | $this->performanceMonitor->stop(); |
||
| 28 | } |
||
| 29 | |||
| 30 | public function getPerformanceMetrics(): PerformanceMetricsDTO |
||
| 31 | { |
||
| 32 | return $this->performanceMonitor->getPerformanceMetrics(); |
||
| 33 | } |
||
| 34 | |||
| 35 | public function hasExceededThreshold(): bool |
||
| 36 | { |
||
| 37 | return $this->cds->hasExceededThreshold() || $this->comToLoc->hasExceededThreshold(); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param CommentStatisticsDTO[] $commentStatistics |
||
| 42 | */ |
||
| 43 | public function calculateCDS(array $commentStatistics): float |
||
| 44 | { |
||
| 45 | return $this->cds->calculateCDS($commentStatistics); |
||
| 46 | } |
||
| 47 | |||
| 48 | public function prepareCDS(float $cds): CdsDTO |
||
| 49 | { |
||
| 50 | return $this->cds->prepareCDS($cds); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @param CommentStatisticsDTO[] $commentStatistics |
||
| 55 | */ |
||
| 56 | public function prepareComToLoc(array $commentStatistics, int $linesOfCode): ComToLocDTO |
||
| 57 | { |
||
| 58 | return $this->comToLoc->prepareComToLoc($commentStatistics, $linesOfCode); |
||
| 59 | } |
||
| 60 | } |
||
| 61 |