19declare(strict_types=1);
43 public function normalize($value): array|float|bool|
int|string|null
50 'id' => $this->tt->normalize(
new Id($value->getId(),
'suggested_solution')),
51 'question_id' => $this->tt->normalize(
new Id($value->getQuestionId(),
'question')),
52 'subquestion_index' => $value->getSubquestionIndex(),
53 'import_id' => $value->getImportId(),
54 'last_update' => $this->tt->normalize($value->getLastUpdate()),
58 $normalized[
'type'] = $value->getType();
59 $normalized[
'internal_link'] = $value->getInternalLink();
63 $normalized[
'type'] = $value->getType();
64 $normalized[
'title'] = $value->getTitle();
65 $normalized[
'mime'] = $value->getMime();
66 $normalized[
'size'] = $value->getSize();
68 $normalized[
'file'] = $this->tt->normalize(
80 if ($type !== SuggestedSolution::class && !in_array(SuggestedSolution::class, class_parents($type))) {
85 $denormalized_type = $this->tt->string($value[
'type']);
86 if ($type === SuggestedSolution::class) {
87 $type = match($denormalized_type) {
97 $id = $this->tt->denormalize($value[
'id'], Id::class)->getId();
98 $question_id = $this->tt->denormalize($value[
'question_id'], Id::class)->getId();
99 $subquestion_index = $this->tt->int($value[
'subquestion_index']);
100 $import_id = $this->tt->string($value[
'import_id']);
101 $last_update = $this->tt->denormalize($value[
'last_update'], \DateTimeImmutable::class);
104 case SuggestedSolutionFile::class:
114 ->
withTitle($this->tt->string($value[
'title']))
115 ->withFilename($this->tt->denormalize($value[
'file'], QuestionImage::class)->getFilename())
116 ->withMime($this->tt->string($value[
'mime']))
117 ->withSize($this->tt->int($value[
'size']));
118 case SuggestedSolutionLink::class:
126 $this->tt->string($value[
'internal_link'])
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Wrapper object for an object identifier and an optional object type the identifier belongs to.
Exception thrown when a value cannot be normalized or denormalized.
Wrapper object for an image file within a question (e.g.
<SuggestedSolution, array>
normalize($value)
Converts a value into a normalized form.
__construct(private readonly Transformations $tt,)
denormalize(array|float|bool|int|string|null $value, string $type)
Converts a normalized form back into a value.
a suggested solution for file-contents
a suggested solution that links to some other object/place
A Normalizer is responsible for converting a value into a normalized form and back.