Skip to content

Commit a60eda9

Browse files
committed
misc
1 parent 142db51 commit a60eda9

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

src/Analyzer/ClassMethodContextDefinitionsAnalyzer.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,30 @@ public function __construct(
2424
) {
2525
}
2626

27+
/**
28+
* @param SplFileInfo[] $contextFileInfos
29+
* @return ClassMethodContextDefinition[]
30+
*/
31+
public function resolve(array $contextFileInfos): array
32+
{
33+
$classMethodContextDefinitionByClassMethodHash = $this->resolveAndGroupByContentHash($contextFileInfos);
34+
35+
$classMethodContextDefinitions = [];
36+
foreach ($classMethodContextDefinitionByClassMethodHash as $currentClassMethodContextDefinitions) {
37+
$classMethodContextDefinitions = array_merge(
38+
$classMethodContextDefinitions,
39+
$currentClassMethodContextDefinitions
40+
);
41+
}
42+
43+
return $classMethodContextDefinitions;
44+
}
45+
2746
/**
2847
* @param SplFileInfo[] $contextFileInfos
2948
* @return array<string, ClassMethodContextDefinition[]>
3049
*/
31-
public function analyseContextFiles(array $contextFileInfos): array
50+
public function resolveAndGroupByContentHash(array $contextFileInfos): array
3251
{
3352
$classMethodContextDefinitionByClassMethodHash = [];
3453

src/Command/DuplicatedDefinitionsCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4747
return self::FAILURE;
4848
}
4949

50-
$classMethodContextDefinitionByClassMethodHash = $this->classMethodContextDefinitionsAnalyzer->analyseContextFiles(
50+
$classMethodContextDefinitionByClassMethodHash = $this->classMethodContextDefinitionsAnalyzer->resolveAndGroupByContentHash(
5151
$contextFileInfos
5252
);
5353

src/Command/StatsCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Behastan\Command;
66

7+
use Behastan\Analyzer\ClassMethodContextDefinitionsAnalyzer;
78
use Behastan\DefinitionMasksResolver;
89
use Behastan\Finder\BehatMetafilesFinder;
910
use Behastan\UsedInstructionResolver;
@@ -21,6 +22,7 @@ public function __construct(
2122
private readonly BehatMetafilesFinder $behatMetafilesFinder,
2223
private readonly DefinitionMasksResolver $definitionMasksResolver,
2324
private readonly UsedInstructionResolver $usedInstructionResolver,
25+
private readonly ClassMethodContextDefinitionsAnalyzer $classMethodContextDefinitionsAnalyzer,
2426
) {
2527
parent::__construct();
2628
}
@@ -57,9 +59,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5759

5860
$this->symfonyStyle->title('Usage stats for PHP definitions in *Feature files');
5961

60-
$maskCollection = $this->definitionMasksResolver->resolve($contextFiles);
62+
// $maskCollection = $this->definitionMasksResolver->resolve($contextFiles);
6163
$featureInstructions = $this->usedInstructionResolver->resolveInstructionsFromFeatureFiles($featureFiles);
6264

65+
$classMethodContextDefinitions = $this->classMethodContextDefinitionsAnalyzer->resolve($contextFiles);
66+
6367
dump(123);
6468
die;
6569

0 commit comments

Comments
 (0)