ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilObjQuestionPoolNormalizer.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26
31{
32 #[\Override]
33 public function normalize($value): array|float|bool|int|string|null
34 {
35 if (!($value instanceof \ilObjQuestionPool)) {
36 throw new NormalizingException('Invalid value', $value);
37 }
38
39 $normalized = parent::normalize($value);
40 $normalized['skill_service_enabled'] = $value->isSkillServiceEnabled();
41
42 return $normalized;
43 }
44
45 #[\Override]
46 public function denormalize(array|float|bool|int|string|null $value, string $type): \ilObjQuestionPool
47 {
48 if ($type !== \ilObjQuestionPool::class) {
49 throw new NormalizingException("Invalid type for ilObjQuestionPool: {$type}");
50 }
51
53 $object = parent::denormalize($value, \ilObjQuestionPool::class);
54 $object->setSkillServiceEnabled($this->tt->bool($value['skill_service_enabled']));
55
56 return $object;
57 }
58}
Exception thrown when a value cannot be normalized or denormalized.
A Normalizer is responsible for converting a value into a normalized form and back.
Definition: Normalizer.php:35
denormalize(array|float|bool|int|string|null $normalized, string $type)
Converts a normalized form back into a value.