Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
34.78% |
16 / 46 |
|
45.45% |
10 / 22 |
CRAP | |
0.00% |
0 / 1 |
Metadata | |
34.78% |
16 / 46 |
|
45.45% |
10 / 22 |
156.26 | |
0.00% |
0 / 1 |
getLabel | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setLabel | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setType | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getValues | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setValues | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addValue | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getUri | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setUri | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getPropertyUri | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setPropertyUri | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getAlias | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setAlias | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getClassLabel | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setClassLabel | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
isDuplicated | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
markAsDuplicated | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getSortId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setSortId | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
isSortable | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setIsSortable | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
jsonSerialize | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * This program is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU General Public License |
6 | * as published by the Free Software Foundation; under version 2 |
7 | * of the License (non-upgradable). |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write to the Free Software |
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | * |
18 | * Copyright (c) 2020|2021 (original work) Open Assessment Technologies SA; |
19 | */ |
20 | |
21 | declare(strict_types=1); |
22 | |
23 | namespace oat\tao\model\Lists\Business\Domain; |
24 | |
25 | use JsonSerializable; |
26 | use tao_helpers_Uri; |
27 | |
28 | class Metadata implements JsonSerializable |
29 | { |
30 | /** @var string */ |
31 | private $label; |
32 | |
33 | /** @var string|null */ |
34 | private $alias; |
35 | |
36 | /** @var string */ |
37 | private $type; |
38 | |
39 | /** @var array */ |
40 | private $values = []; |
41 | |
42 | /** @var string|null */ |
43 | private $uri; |
44 | |
45 | /** @var string|null */ |
46 | private $propertyUri; |
47 | |
48 | /** @var string|null */ |
49 | private $classLabel; |
50 | |
51 | /** @var bool */ |
52 | private $isDuplicated = false; |
53 | |
54 | /** @var bool */ |
55 | private $isSortable = false; |
56 | |
57 | /** @var string */ |
58 | private $sortId; |
59 | |
60 | public function getLabel(): string |
61 | { |
62 | return $this->label; |
63 | } |
64 | |
65 | public function setLabel(string $label): Metadata |
66 | { |
67 | $this->label = $label; |
68 | |
69 | return $this; |
70 | } |
71 | |
72 | public function getType(): string |
73 | { |
74 | return $this->type; |
75 | } |
76 | |
77 | public function setType(string $type): Metadata |
78 | { |
79 | $this->type = $type; |
80 | |
81 | return $this; |
82 | } |
83 | |
84 | public function getValues(): ?array |
85 | { |
86 | return $this->values; |
87 | } |
88 | |
89 | public function setValues(?array $values): Metadata |
90 | { |
91 | $this->values = $values; |
92 | |
93 | return $this; |
94 | } |
95 | |
96 | public function addValue(string $value): Metadata |
97 | { |
98 | array_push($this->values, $value); |
99 | |
100 | return $this; |
101 | } |
102 | |
103 | public function getUri(): ?string |
104 | { |
105 | return $this->uri; |
106 | } |
107 | |
108 | public function setUri(?string $uri): Metadata |
109 | { |
110 | $this->uri = $uri; |
111 | |
112 | return $this; |
113 | } |
114 | |
115 | public function getPropertyUri(): ?string |
116 | { |
117 | return $this->propertyUri; |
118 | } |
119 | |
120 | public function setPropertyUri(?string $propertyUri): Metadata |
121 | { |
122 | $this->propertyUri = $propertyUri; |
123 | |
124 | return $this; |
125 | } |
126 | |
127 | public function getAlias(): ?string |
128 | { |
129 | return $this->alias; |
130 | } |
131 | |
132 | public function setAlias(?string $alias): self |
133 | { |
134 | $this->alias = $alias; |
135 | |
136 | return $this; |
137 | } |
138 | |
139 | public function getClassLabel(): ?string |
140 | { |
141 | return $this->classLabel; |
142 | } |
143 | |
144 | public function setClassLabel(?string $classLabel): self |
145 | { |
146 | $this->classLabel = $classLabel; |
147 | |
148 | return $this; |
149 | } |
150 | |
151 | public function isDuplicated(): bool |
152 | { |
153 | return $this->isDuplicated; |
154 | } |
155 | |
156 | public function markAsDuplicated(): self |
157 | { |
158 | $this->isDuplicated = true; |
159 | |
160 | return $this; |
161 | } |
162 | |
163 | public function getSortId(): ?string |
164 | { |
165 | return $this->sortId; |
166 | } |
167 | |
168 | public function setSortId(string $sortId = null): self |
169 | { |
170 | $this->sortId = $sortId; |
171 | |
172 | return $this; |
173 | } |
174 | |
175 | public function isSortable(): bool |
176 | { |
177 | return $this->isSortable; |
178 | } |
179 | |
180 | public function setIsSortable(bool $isSortable): self |
181 | { |
182 | $this->isSortable = $isSortable; |
183 | |
184 | return $this; |
185 | } |
186 | |
187 | public function jsonSerialize(): array |
188 | { |
189 | return [ |
190 | 'sortId' => $this->getSortId(), |
191 | 'isSortable' => $this->isSortable(), |
192 | 'label' => $this->getLabel(), |
193 | 'alias' => $this->getAlias(), |
194 | 'type' => $this->getType(), |
195 | 'values' => $this->getValues(), |
196 | 'isDuplicated' => $this->isDuplicated(), |
197 | 'propertyUri' => tao_helpers_Uri::encode($this->getPropertyUri()), |
198 | 'uri' => $this->getUri(), |
199 | 'class' => [ |
200 | 'label' => $this->getClassLabel(), |
201 | ], |
202 | ]; |
203 | } |
204 | } |