ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SuggestedSolution.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28abstract class SuggestedSolution
29{
30 public const TYPE_LM = 'lm';
31 public const TYPE_LM_CHAPTER = 'st';
32 public const TYPE_LM_PAGE = 'pg';
33 public const TYPE_GLOSARY_TERM = 'git';
34 public const TYPE_FILE = 'file';
35
36 public const TYPES = [
37 self::TYPE_LM => 'obj_lm',
38 self::TYPE_LM_CHAPTER => 'obj_st',
39 self::TYPE_LM_PAGE => 'obj_pg',
40 self::TYPE_GLOSARY_TERM => 'glossary_term',
41 self::TYPE_FILE => 'fileDownload'
42 ];
43
44 protected int $id;
45 protected int $question_id;
46 protected int $subquestion_index;
47 protected string $import_id;
48 protected \DateTimeImmutable $last_update;
49
50 public function __construct(
51 int $id,
52 int $question_id,
54 string $import_id,
55 \DateTimeImmutable $last_update
56 ) {
57 $this->id = $id;
58 $this->question_id = $question_id;
59 $this->subquestion_index = $subquestion_index;
60 $this->import_id = $import_id;
61 $this->last_update = $last_update;
62 }
63
64 abstract public function getType(): string;
65 abstract public function getStorableValue(): string;
66
67 public function getId(): int
68 {
69 return $this->id;
70 }
71 public function withId(int $id): static
72 {
73 $clone = clone $this;
74 $clone->id = $id;
75 return $clone;
76 }
77
78 public function getQuestionId(): int
79 {
80 return $this->question_id;
81 }
82 public function withQuestionId(int $question_id): static
83 {
84 $clone = clone $this;
85 $clone->question_id = $question_id;
86 return $clone;
87 }
88
89 public function getImportId(): string
90 {
91 return $this->import_id;
92 }
93 public function withImportId(string $import_id): static
94 {
95 $clone = clone $this;
96 $clone->import_id = $import_id;
97 return $clone;
98 }
99
100 public function getSubquestionIndex(): int
101 {
103 }
104 public function withSubquestionIndex(int $subquestion_index): static
105 {
106 $clone = clone $this;
107 $clone->subquestion_index = $subquestion_index;
108 return $clone;
109 }
110
111 public function getLastUpdate(): \DateTimeImmutable
112 {
113 return $this->last_update;
114 }
115
116 public function isOfTypeFile(): bool
117 {
118 return $this->getType() === self::TYPE_FILE;
119 }
120
121 public function isOfTypeLink(): bool
122 {
123 return in_array(
124 $this->getType(),
125 [
126 self::TYPE_LM,
127 self::TYPE_LM_CHAPTER,
128 self::TYPE_LM_PAGE,
129 self::TYPE_GLOSARY_TERM,
130 ]
131 );
132 }
133}
__construct(int $id, int $question_id, int $subquestion_index, string $import_id, \DateTimeImmutable $last_update)