Total Complexity | 5 |
Total Lines | 23 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
21 | final class SourceCodeFinder implements CodeFinder |
||
22 | { |
||
23 | 29 | public static function fromConfiguration(CodeFinderConfiguration $configuration): SourceCodeFinder |
|
24 | { |
||
25 | 29 | $finder = new Finder(); |
|
26 | 29 | if (! $configuration->recursive()) { |
|
27 | 17 | $finder->depth(0); |
|
28 | } |
||
29 | 29 | return new self($finder); |
|
30 | } |
||
31 | |||
32 | 29 | private function __construct(private readonly Finder $finder) |
|
|
|||
33 | { |
||
34 | } |
||
35 | |||
36 | 25 | public function find(CodebaseDirectory $directory): SourceCode |
|
37 | { |
||
38 | 25 | $sourceCode = new SourceCode(); |
|
39 | 25 | $this->finder->in($directory->absolutePath())->files()->name('*.php')->sortByName(); |
|
40 | 25 | foreach ($this->finder as $file) { |
|
41 | 24 | $sourceCode->add($file->getContents()); |
|
42 | } |
||
43 | 25 | return $sourceCode; |
|
44 | } |
||
46 |