Conditions | 5 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
34 | public function buildSource(): Source |
||
35 | { |
||
36 | $iterator = new \DirectoryIterator($this->directoryPath); |
||
37 | $combinedSource = ''; |
||
38 | |||
39 | foreach ($iterator as $item) { |
||
40 | // Skip directories and dot files |
||
41 | if ($item->isDot() || !$item->isFile()) { |
||
42 | continue; |
||
43 | } |
||
44 | |||
45 | $itemPath = $item->getPathname(); |
||
46 | |||
47 | if (!$item->isReadable()) { |
||
48 | throw new InvariantException(sprintf('The file %s is not readable', $itemPath)); |
||
49 | } |
||
50 | |||
51 | $combinedSource .= \file_get_contents($itemPath); |
||
52 | } |
||
53 | |||
54 | return new Source($combinedSource); |
||
55 | } |
||
57 |