| Conditions | 7 |
| Paths | 20 |
| Total Lines | 26 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 7 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | 2 | public function getContents(): iterable |
|
| 31 | { |
||
| 32 | 2 | $filesInDir = new \RecursiveIteratorIterator( |
|
| 33 | 2 | new \RecursiveDirectoryIterator( |
|
| 34 | 2 | $this->dirPath, |
|
| 35 | 2 | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME |
|
| 36 | ), |
||
| 37 | \RecursiveIteratorIterator::SELF_FIRST |
||
| 38 | 2 | ); |
|
| 39 | 1 | ||
| 40 | if ($this->pattern) { |
||
| 41 | $filesInDir = new \RegexIterator($filesInDir, $this->pattern, \RegexIterator::GET_MATCH); |
||
| 42 | } |
||
| 43 | 2 | ||
| 44 | 2 | /** @var \SplFileInfo|string|array $file */ |
|
| 45 | 1 | foreach ($filesInDir as $file) { |
|
| 46 | 1 | if (is_string($file)) { |
|
| 47 | $file = new \SplFileInfo($file); |
||
| 48 | 1 | } elseif (is_array($file)) { |
|
| 49 | // When regex pattern is used, an array containing the file path in its first element is returned |
||
| 50 | $file = new \SplFileInfo(current($file)); |
||
| 51 | 2 | } |
|
| 52 | 2 | ||
| 53 | if (!$file->isDir()) { |
||
| 54 | if ($file->getRealPath() !== false) { |
||
| 55 | 2 | yield current((new File($file->getRealPath()))->toTexts()); |
|
|
|
|||
| 56 | } |
||
| 72 |