Total Complexity | 5 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
11 | class CodeFinder |
||
12 | { |
||
13 | /** @var Finder */ |
||
14 | private $finder; |
||
15 | |||
16 | /** @var string[] */ |
||
17 | private $files; |
||
18 | |||
19 | 36 | public function __construct(Finder $finder = null) |
|
20 | { |
||
21 | 36 | $this->finder = $finder ?? new Finder(); |
|
22 | 36 | $this->files = []; |
|
23 | 36 | } |
|
24 | |||
25 | |||
26 | 12 | public function addDirectory(string $directory, bool $recursive = true): void |
|
27 | { |
||
28 | 12 | if (!$recursive) { |
|
29 | 6 | $this->finder->depth(0); |
|
30 | } |
||
31 | 12 | $this->finder->in($directory)->files()->name('*.php'); |
|
32 | 12 | foreach ($this->finder as $file) { |
|
33 | 12 | $this->files[] = $file->getContents(); |
|
34 | } |
||
35 | 12 | } |
|
36 | |||
37 | /** @return string[] */ |
||
38 | 15 | public function files(): array |
|
41 | } |
||
42 | } |
||
43 |