Initial survey bundle import

This commit is contained in:
Jürgen Mummert
2026-05-17 17:31:28 +02:00
commit b8475e3a57
84 changed files with 7157 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace Mummert\SurveyBundle\QuestionType;
final class QuestionTypeRegistry
{
/**
* @var array<string, QuestionTypeInterface>
*/
private array $questionTypes = [];
public function __construct(iterable $questionTypes)
{
foreach ($questionTypes as $questionType) {
if (!$questionType instanceof QuestionTypeInterface) {
continue;
}
$this->questionTypes[$questionType->getName()] = $questionType;
}
}
public function get(string $type): QuestionTypeInterface
{
if (!isset($this->questionTypes[$type])) {
throw new \InvalidArgumentException(sprintf('Unbekannter Fragetyp "%s".', $type));
}
return $this->questionTypes[$type];
}
/**
* @return array<string, string>
*/
public function getChoices(): array
{
return [
'Ja-Nein-Frage' => 'yes_no_maybe',
'Offene Frage' => 'text',
'Bewertungsfrage' => 'range',
'Single/Multiple-Choice' => 'choice',
];
}
}