-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTemplateFinder.php
49 lines (40 loc) · 1.45 KB
/
TemplateFinder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
declare(strict_types=1);
namespace a9f\FractorRuleGenerator\Finder;
use a9f\Fractor\FileSystem\FileInfoFactory;
use Symfony\Component\Finder\SplFileInfo;
final readonly class TemplateFinder
{
/**
* @var string
*/
public const TEMPLATES_DIRECTORY = __DIR__ . '/../../templates';
public function __construct(
private FileInfoFactory $fileInfoFactory
) {
}
/**
* @return SplFileInfo[]
*/
public function find(string $fixtureFileExtension): array
{
$filePaths = $this->addRuleAndTestCase($fixtureFileExtension);
$smartFileInfos = [];
foreach ($filePaths as $filePath) {
$smartFileInfos[] = $this->fileInfoFactory->createFileInfoFromPath($filePath);
}
return $smartFileInfos;
}
/**
* @return array<int, string>
*/
private function addRuleAndTestCase(string $fixtureFileExtension): array
{
return [
__DIR__ . '/../../templates/rules/TYPO3__MajorPrefixed__/__Type__/__Name__.php',
__DIR__ . '/../../templates/rules-tests/TYPO3__MajorPrefixed__/__Type__/__Test_Directory__/__Name__Test.php.inc',
__DIR__ . '/../../templates/rules-tests/TYPO3__MajorPrefixed__/__Type__/__Test_Directory__/Fixtures/fixture.' . $fixtureFileExtension . '.fixture',
__DIR__ . '/../../templates/rules-tests/TYPO3__MajorPrefixed__/__Type__/__Test_Directory__/config/fractor.php.inc',
];
}
}