getQuestionFiles() as $file) { $yamlFile = Yaml::parseFile($file->getRealPath()); $questions = array_merge($questions, $yamlFile['questions']); } return $questions; } private function getQuestionFiles(): array { $finder = new Finder(); return iterator_to_array($finder->files()->in($this->paths)->name('*.yaml')); } }