2021-04-12 10:34:04 +00:00
|
|
|
<?php
|
|
|
|
|
2021-05-09 20:15:43 +00:00
|
|
|
declare (strict_types=1);
|
2024-01-02 02:40:38 +00:00
|
|
|
namespace Rector\ValueObjectFactory\Application;
|
2021-04-12 10:34:04 +00:00
|
|
|
|
2022-06-06 17:12:56 +00:00
|
|
|
use Rector\Caching\Detector\ChangedFilesDetector;
|
2024-01-02 02:40:38 +00:00
|
|
|
use Rector\FileSystem\FilesFinder;
|
|
|
|
use Rector\ValueObject\Configuration;
|
2021-04-12 10:34:04 +00:00
|
|
|
/**
|
2024-01-02 02:40:38 +00:00
|
|
|
* @see \Rector\ValueObject\Application\File
|
2021-04-12 10:34:04 +00:00
|
|
|
*/
|
|
|
|
final class FileFactory
|
|
|
|
{
|
|
|
|
/**
|
2023-06-11 23:01:39 +00:00
|
|
|
* @readonly
|
2024-01-02 02:40:38 +00:00
|
|
|
* @var \Rector\FileSystem\FilesFinder
|
2021-04-12 10:34:04 +00:00
|
|
|
*/
|
2021-05-10 23:39:21 +00:00
|
|
|
private $filesFinder;
|
2021-06-22 17:07:57 +00:00
|
|
|
/**
|
2023-06-11 23:01:39 +00:00
|
|
|
* @readonly
|
2021-06-22 17:07:57 +00:00
|
|
|
* @var \Rector\Caching\Detector\ChangedFilesDetector
|
|
|
|
*/
|
|
|
|
private $changedFilesDetector;
|
2023-08-23 10:40:53 +00:00
|
|
|
public function __construct(FilesFinder $filesFinder, ChangedFilesDetector $changedFilesDetector)
|
2021-04-12 10:34:04 +00:00
|
|
|
{
|
|
|
|
$this->filesFinder = $filesFinder;
|
2021-06-22 17:07:57 +00:00
|
|
|
$this->changedFilesDetector = $changedFilesDetector;
|
2021-04-12 10:34:04 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @param string[] $paths
|
2022-09-01 09:30:44 +00:00
|
|
|
* @return string[]
|
2021-04-12 10:34:04 +00:00
|
|
|
*/
|
2023-02-06 14:23:37 +00:00
|
|
|
public function findFilesInPaths(array $paths, Configuration $configuration) : array
|
2021-04-12 10:34:04 +00:00
|
|
|
{
|
2021-06-22 19:34:44 +00:00
|
|
|
if ($configuration->shouldClearCache()) {
|
2021-06-22 17:07:57 +00:00
|
|
|
$this->changedFilesDetector->clear();
|
|
|
|
}
|
2023-08-23 10:40:53 +00:00
|
|
|
$supportedFileExtensions = $configuration->getFileExtensions();
|
2024-01-13 19:16:19 +00:00
|
|
|
return $this->filesFinder->findInDirectoriesAndFiles($paths, $supportedFileExtensions);
|
2021-12-28 12:08:43 +00:00
|
|
|
}
|
2021-04-12 10:34:04 +00:00
|
|
|
}
|