*/ 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 */ public function getChoices(): array { return [ 'Ja-Nein-Frage' => 'yes_no_maybe', 'Offene Frage' => 'text', 'Bewertungsfrage' => 'range', 'Single/Multiple-Choice' => 'choice', ]; } }