1 | <?php |
||
2 | |||
3 | namespace FAPI\Localise\Model\Translation; |
||
4 | |||
5 | use FAPI\Localise\Model\CreatableFromArray; |
||
6 | |||
7 | /** |
||
8 | * @author Tobias Nyholm <[email protected]> |
||
9 | */ |
||
10 | class Translation implements CreatableFromArray |
||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | private $id = ''; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private $type = ''; |
||
21 | |||
22 | /** |
||
23 | * @var bool |
||
24 | */ |
||
25 | private $translated = false; |
||
26 | |||
27 | /** |
||
28 | * @var bool |
||
29 | */ |
||
30 | private $flagged = false; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | private $status = ''; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | private $translation = ''; |
||
41 | |||
42 | /** |
||
43 | * @var int |
||
44 | */ |
||
45 | private $revision = 0; |
||
46 | |||
47 | /** |
||
48 | * @var int |
||
49 | */ |
||
50 | private $comments = 0; |
||
51 | |||
52 | /** |
||
53 | * @var string |
||
54 | */ |
||
55 | private $modified = ''; |
||
56 | |||
57 | /** |
||
58 | * @var array |
||
59 | */ |
||
60 | private $author = []; |
||
61 | |||
62 | /** |
||
63 | * @var array |
||
64 | */ |
||
65 | private $flagger = []; |
||
66 | |||
67 | /** |
||
68 | * @var array |
||
69 | */ |
||
70 | private $locale = []; |
||
71 | |||
72 | /** |
||
73 | * @var array |
||
74 | */ |
||
75 | private $plurals = []; |
||
76 | |||
77 | private function __construct() |
||
78 | { |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * @param array $data |
||
83 | * |
||
84 | * @return Translation |
||
85 | */ |
||
86 | public static function createFromArray(array $data) |
||
87 | { |
||
88 | $self = new self(); |
||
89 | |||
90 | if (isset($data['id'])) { |
||
91 | $self->setId($data['id']); |
||
92 | } |
||
93 | if (isset($data['type'])) { |
||
94 | $self->setType($data['type']); |
||
95 | } |
||
96 | if (isset($data['translated'])) { |
||
97 | $self->setTranslated($data['translated']); |
||
98 | } |
||
99 | if (isset($data['flagged'])) { |
||
100 | $self->setFlagged($data['flagged']); |
||
101 | } |
||
102 | if (isset($data['status'])) { |
||
103 | $self->setStatus($data['status']); |
||
104 | } |
||
105 | if (isset($data['translation'])) { |
||
106 | $self->setTranslation($data['translation']); |
||
107 | } |
||
108 | if (isset($data['revision'])) { |
||
109 | $self->setRevision($data['revision']); |
||
110 | } |
||
111 | if (isset($data['comments'])) { |
||
112 | $self->setComments($data['comments']); |
||
113 | } |
||
114 | if (isset($data['modified'])) { |
||
115 | $self->setModified($data['modified']); |
||
116 | } |
||
117 | if (isset($data['author'])) { |
||
118 | $self->setAuthor($data['author']); |
||
119 | } |
||
120 | if (isset($data['flagger'])) { |
||
121 | $self->setFlagger($data['flagger']); |
||
122 | } |
||
123 | if (isset($data['locale'])) { |
||
124 | $self->setLocale($data['locale']); |
||
125 | } |
||
126 | if (isset($data['plurals'])) { |
||
127 | $self->setPlurals($data['plurals']); |
||
128 | } |
||
129 | |||
130 | return $self; |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * @return string |
||
135 | */ |
||
136 | public function getId(): string |
||
137 | { |
||
138 | return $this->id; |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * @param string $id |
||
143 | */ |
||
144 | private function setId($id) |
||
145 | { |
||
146 | $this->id = $id; |
||
147 | } |
||
148 | |||
149 | /** |
||
150 | * @return string |
||
151 | */ |
||
152 | public function getType(): string |
||
153 | { |
||
154 | return $this->type; |
||
155 | } |
||
156 | |||
157 | /** |
||
158 | * @param string $type |
||
159 | */ |
||
160 | private function setType($type) |
||
161 | { |
||
162 | $this->type = $type; |
||
163 | } |
||
164 | |||
165 | /** |
||
166 | * @return string |
||
167 | */ |
||
168 | public function getTranslated(): bool |
||
169 | { |
||
170 | return $this->translated; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
171 | } |
||
172 | |||
173 | /** |
||
174 | * @param bool $translated |
||
175 | */ |
||
176 | private function setTranslated($translated) |
||
177 | { |
||
178 | $this->translated = (bool) $translated; |
||
179 | } |
||
180 | |||
181 | /** |
||
182 | * @return string |
||
183 | */ |
||
184 | public function getFlagged(): bool |
||
185 | { |
||
186 | return $this->flagged; |
||
0 ignored issues
–
show
|
|||
187 | } |
||
188 | |||
189 | /** |
||
190 | * @param bool $flagged |
||
191 | */ |
||
192 | private function setFlagged($flagged) |
||
193 | { |
||
194 | $this->flagged = (bool) $flagged; |
||
195 | } |
||
196 | |||
197 | /** |
||
198 | * @return string |
||
199 | */ |
||
200 | public function getStatus(): string |
||
201 | { |
||
202 | return $this->status; |
||
203 | } |
||
204 | |||
205 | /** |
||
206 | * @param string $status |
||
207 | */ |
||
208 | private function setStatus($status) |
||
209 | { |
||
210 | $this->status = $status; |
||
211 | } |
||
212 | |||
213 | /** |
||
214 | * @return string |
||
215 | */ |
||
216 | public function getTranslation(): string |
||
217 | { |
||
218 | return $this->translation; |
||
219 | } |
||
220 | |||
221 | /** |
||
222 | * @param string $translation |
||
223 | */ |
||
224 | private function setTranslation($translation) |
||
225 | { |
||
226 | $this->translation = $translation; |
||
227 | } |
||
228 | |||
229 | /** |
||
230 | * @return string |
||
231 | */ |
||
232 | public function getRevision(): int |
||
233 | { |
||
234 | return $this->revision; |
||
235 | } |
||
236 | |||
237 | /** |
||
238 | * @param int $revision |
||
239 | */ |
||
240 | private function setRevision(int $revision) |
||
241 | { |
||
242 | $this->revision = $revision; |
||
243 | } |
||
244 | |||
245 | /** |
||
246 | * @return int |
||
247 | */ |
||
248 | public function getComments(): int |
||
249 | { |
||
250 | return $this->comments; |
||
251 | } |
||
252 | |||
253 | /** |
||
254 | * @param int $comments |
||
255 | */ |
||
256 | private function setComments(int $comments) |
||
257 | { |
||
258 | $this->comments = $comments; |
||
259 | } |
||
260 | |||
261 | /** |
||
262 | * @return string |
||
263 | */ |
||
264 | public function getModified(): string |
||
265 | { |
||
266 | return $this->modified; |
||
267 | } |
||
268 | |||
269 | /** |
||
270 | * @param string $modified |
||
271 | */ |
||
272 | private function setModified($modified) |
||
273 | { |
||
274 | $this->modified = $modified; |
||
275 | } |
||
276 | |||
277 | /** |
||
278 | * @return array |
||
279 | */ |
||
280 | public function getAuthor(): array |
||
281 | { |
||
282 | return $this->author; |
||
283 | } |
||
284 | |||
285 | /** |
||
286 | * @param array $author |
||
287 | */ |
||
288 | private function setAuthor($author) |
||
289 | { |
||
290 | $this->author = $author; |
||
291 | } |
||
292 | |||
293 | /** |
||
294 | * @return array |
||
295 | */ |
||
296 | public function getFlagger(): array |
||
297 | { |
||
298 | return $this->flagger; |
||
299 | } |
||
300 | |||
301 | /** |
||
302 | * @param array $flagger |
||
303 | */ |
||
304 | private function setFlagger($flagger) |
||
305 | { |
||
306 | $this->flagger = $flagger; |
||
307 | } |
||
308 | |||
309 | /** |
||
310 | * @return array |
||
311 | */ |
||
312 | public function getLocale(): array |
||
313 | { |
||
314 | return $this->locale; |
||
315 | } |
||
316 | |||
317 | /** |
||
318 | * @param array $locale |
||
319 | */ |
||
320 | private function setLocale($locale) |
||
321 | { |
||
322 | $this->locale = $locale; |
||
323 | } |
||
324 | |||
325 | /** |
||
326 | * @return array |
||
327 | */ |
||
328 | public function getPlurals(): array |
||
329 | { |
||
330 | return $this->plurals; |
||
331 | } |
||
332 | |||
333 | /** |
||
334 | * @param array $plurals |
||
335 | */ |
||
336 | private function setPlurals($plurals) |
||
337 | { |
||
338 | $this->plurals = $plurals; |
||
339 | } |
||
340 | } |
||
341 |