31 lines
688 B
PHP
31 lines
688 B
PHP
<?php
|
|
|
|
namespace App\Service;
|
|
|
|
use Symfony\Component\Finder\Finder;
|
|
use Symfony\Component\Yaml\Yaml;
|
|
|
|
class QuestionsService
|
|
{
|
|
public function __construct(private array $paths = [])
|
|
{
|
|
}
|
|
|
|
public function getQuestions(): array
|
|
{
|
|
$questions = [];
|
|
foreach ($this->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'));
|
|
}
|
|
} |