Skip to content

Commit bd747db

Browse files
committed
refactor analyze task
1 parent 96f4190 commit bd747db

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

src/AnalyzeComments/Analyzer/Analyzer.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ final class Analyzer
2626
public function __construct(
2727
private readonly ConfigDTO $configDTO,
2828
private readonly CommentFactory $commentFactory,
29-
private readonly MissingDocBlockAnalyzer $missingDocBlock,
3029
private readonly MetricsFacade $metrics,
31-
private readonly MissingDocBlockAnalyzer $docBlockAnalyzer,
30+
private readonly MissingDocBlockAnalyzer $missingDocBlockAnalyzer,
3231
private readonly BaselineStorageInterface $baselineStorage,
3332
private readonly CacheInterface $cache,
3433
private readonly CommentStatisticsAggregator $statisticsAggregator,
@@ -45,12 +44,11 @@ public function analyze(iterable $files): Report
4544
$filesAnalyzed = 0;
4645

4746
foreach ($files as $file) {
48-
$task = new AnalyzeFileTask(
47+
$task = new FileCommentFinder(
4948
$this->cache,
50-
$this->docBlockAnalyzer,
51-
$this->missingDocBlock,
5249
$this->commentFactory,
5350
$this->configDTO,
51+
$this->missingDocBlockAnalyzer,
5452
);
5553

5654
$response = $task->run($file);
@@ -77,7 +75,7 @@ private function checkThresholdsExceeded(): bool
7775
if ($this->metrics->hasExceededThreshold()) {
7876
return true;
7977
}
80-
if ($this->missingDocBlock->hasExceededThreshold()) {
78+
if ($this->missingDocBlockAnalyzer->hasExceededThreshold()) {
8179
return true;
8280
}
8381
foreach ($this->commentFactory->getCommentTypes() as $commentType) {

src/AnalyzeComments/Analyzer/AnalyzerFactory.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public function getAnalyzer(
3333
return new Analyzer(
3434
$configDto,
3535
$commentFactory,
36-
$missingDocBlock,
3736
$metrics,
3837
$missingDocBlock,
3938
$baselineStorage,

src/AnalyzeComments/Analyzer/AnalyzeFileTask.php renamed to src/AnalyzeComments/Analyzer/FileCommentFinder.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@
2323
use const T_COMMENT;
2424
use const T_DOC_COMMENT;
2525

26-
final readonly class AnalyzeFileTask
26+
final readonly class FileCommentFinder
2727
{
2828
public function __construct(
2929
private CacheInterface $cache,
30-
private MissingDocBlockAnalyzer $docBlockAnalyzer,
31-
private MissingDocBlockAnalyzer $missingDocBlock,
3230
private CommentFactory $commentFactory,
3331
private ConfigDTO $configDTO,
32+
private MissingDocBlockAnalyzer $missingDocBlockAnalyzer
3433
) {}
3534

3635
/**
@@ -76,7 +75,7 @@ private function analyzeFile(string $filename): array
7675

7776
$comments = $this->getCommentsFromFile($tokens, $filename);
7877
if ($this->shouldAnalyzeMissingDocBlocks()) {
79-
$missingDocBlocks = $this->docBlockAnalyzer->getMissingDocblocks($code, $filename);
78+
$missingDocBlocks = $this->missingDocBlockAnalyzer->getMissingDocblocks($code, $filename);
8079
$comments = array_merge($missingDocBlocks, $comments);
8180
}
8281

@@ -88,7 +87,7 @@ private function shouldAnalyzeMissingDocBlocks(): bool
8887
return
8988
$this->configDTO->getAllowedTypes() === []
9089
|| in_array(
91-
$this->missingDocBlock->getName(),
90+
$this->missingDocBlockAnalyzer->getName(),
9291
$this->configDTO->getAllowedTypes(),
9392
true,
9493
);

0 commit comments

Comments
 (0)