1
|
|
|
<?php |
2
|
|
|
namespace Nkey\DDG\API\Model; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Model for the result of an api query |
6
|
|
|
* |
7
|
|
|
* @author Maik Greubel <[email protected]> |
8
|
|
|
*/ |
9
|
|
|
class QueryResult |
10
|
|
|
{ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* |
14
|
|
|
* @var string |
15
|
|
|
*/ |
16
|
|
|
private $definitionSource; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
private $heading; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* |
26
|
|
|
* @var int |
27
|
|
|
*/ |
28
|
|
|
private $imageWidth; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* |
32
|
|
|
* @var array |
33
|
|
|
*/ |
34
|
|
|
private $relatedTopics; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
private $entity; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* |
44
|
|
|
* @var Metadata |
45
|
|
|
*/ |
46
|
|
|
private $meta; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* |
50
|
|
|
* @var string |
51
|
|
|
*/ |
52
|
|
|
private $type; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* |
56
|
|
|
* @var string |
57
|
|
|
*/ |
58
|
|
|
private $redirect; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* |
62
|
|
|
* @var string |
63
|
|
|
*/ |
64
|
|
|
private $definitionURL; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* |
68
|
|
|
* @var string |
69
|
|
|
*/ |
70
|
|
|
private $abstractURL; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* |
74
|
|
|
* @var string |
75
|
|
|
*/ |
76
|
|
|
private $definition; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* |
80
|
|
|
* @var string |
81
|
|
|
*/ |
82
|
|
|
private $abstractSource; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* |
86
|
|
|
* @var string |
87
|
|
|
*/ |
88
|
|
|
private $infobox; |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* |
92
|
|
|
* @var string |
93
|
|
|
*/ |
94
|
|
|
private $image; |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* |
98
|
|
|
* @var bool |
99
|
|
|
*/ |
100
|
|
|
private $imageIsLogo; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* |
104
|
|
|
* @var string |
105
|
|
|
*/ |
106
|
|
|
private $abstract; |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* |
110
|
|
|
* @var string |
111
|
|
|
*/ |
112
|
|
|
private $abstractText; |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* |
116
|
|
|
* @var string |
117
|
|
|
*/ |
118
|
|
|
private $answerType; |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* |
122
|
|
|
* @var int |
123
|
|
|
*/ |
124
|
|
|
private $imageHeight; |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* |
128
|
|
|
* @var string |
129
|
|
|
*/ |
130
|
|
|
private $answer; |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* |
134
|
|
|
* @var array |
135
|
|
|
*/ |
136
|
|
|
private $results; |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* |
140
|
|
|
* @return string |
141
|
|
|
*/ |
142
|
|
|
public function getDefinitionSource(): string |
143
|
|
|
{ |
144
|
|
|
return $this->definitionSource; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* |
149
|
|
|
* @param string $definitionSource |
150
|
|
|
* @return QueryResult |
151
|
|
|
*/ |
152
|
2 |
|
public function setDefinitionSource(string $definitionSource): QueryResult |
153
|
|
|
{ |
154
|
2 |
|
$this->definitionSource = $definitionSource; |
155
|
2 |
|
return $this; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* |
160
|
|
|
* @return string |
161
|
|
|
*/ |
162
|
|
|
public function getHeading(): string |
163
|
|
|
{ |
164
|
|
|
return $this->heading; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* |
169
|
|
|
* @param string $heading |
170
|
|
|
* @return QueryResult |
171
|
|
|
*/ |
172
|
2 |
|
public function setHeading(string $heading): QueryResult |
173
|
|
|
{ |
174
|
2 |
|
$this->heading = $heading; |
175
|
2 |
|
return $this; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* |
180
|
|
|
* @return int |
181
|
|
|
*/ |
182
|
|
|
public function getImageWidth(): int |
183
|
|
|
{ |
184
|
|
|
return $this->imageWidth; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* |
189
|
|
|
* @param int $imageWidth |
190
|
|
|
* @return QueryResult |
191
|
|
|
*/ |
192
|
2 |
|
public function setImageWidth(int $imageWidth): QueryResult |
193
|
|
|
{ |
194
|
2 |
|
$this->imageWidth = $imageWidth; |
195
|
2 |
|
return $this; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* |
200
|
|
|
* @return mixed |
201
|
|
|
*/ |
202
|
|
|
public function getEntity(): string |
203
|
|
|
{ |
204
|
|
|
return $this->entity; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* |
209
|
|
|
* @param string $entity |
210
|
|
|
* @return QueryResult |
211
|
|
|
*/ |
212
|
2 |
|
public function setEntity(string $entity): QueryResult |
213
|
|
|
{ |
214
|
2 |
|
$this->entity = $entity; |
215
|
2 |
|
return $this; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* |
220
|
|
|
* @return Metadata |
221
|
|
|
*/ |
222
|
|
|
public function getMeta(): Metadata |
223
|
|
|
{ |
224
|
|
|
return $this->meta; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* |
229
|
|
|
* @param Metadata $meta |
230
|
|
|
* @return QueryResult |
231
|
|
|
*/ |
232
|
|
|
public function setMeta(Metadata $meta): QueryResult |
233
|
|
|
{ |
234
|
|
|
$this->meta = $meta; |
235
|
|
|
return $this; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* |
240
|
|
|
* @return string |
241
|
|
|
*/ |
242
|
|
|
public function getType(): string |
243
|
|
|
{ |
244
|
|
|
return $this->type; |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* |
249
|
|
|
* @param string $type |
250
|
|
|
* @return QueryResult |
251
|
|
|
*/ |
252
|
2 |
|
public function setType(string $type): QueryResult |
253
|
|
|
{ |
254
|
2 |
|
$this->type = $type; |
255
|
2 |
|
return $this; |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* |
260
|
|
|
* @return string |
261
|
|
|
*/ |
262
|
|
|
public function getRedirect(): string |
263
|
|
|
{ |
264
|
|
|
return $this->redirect; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* |
269
|
|
|
* @param string $redirect |
270
|
|
|
* @return QueryResult |
271
|
|
|
*/ |
272
|
2 |
|
public function setRedirect(string $redirect): QueryResult |
273
|
|
|
{ |
274
|
2 |
|
$this->redirect = $redirect; |
275
|
2 |
|
return $this; |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
/** |
279
|
|
|
* |
280
|
|
|
* @return string |
281
|
|
|
*/ |
282
|
|
|
public function getDefinitionURL(): string |
283
|
|
|
{ |
284
|
|
|
return $this->definitionURL; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* |
289
|
|
|
* @param string $definitionURL |
290
|
|
|
* @return QueryResult |
291
|
|
|
*/ |
292
|
2 |
|
public function setDefinitionURL(string $definitionURL): QueryResult |
293
|
|
|
{ |
294
|
2 |
|
$this->definitionURL = $definitionURL; |
295
|
2 |
|
return $this; |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
/** |
299
|
|
|
* |
300
|
|
|
* @return string |
301
|
|
|
*/ |
302
|
|
|
public function getAbstractURL(): string |
303
|
|
|
{ |
304
|
|
|
return $this->abstractURL; |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* |
309
|
|
|
* @param string $abstractURL |
310
|
|
|
* @return QueryResult |
311
|
|
|
*/ |
312
|
2 |
|
public function setAbstractURL(string $abstractURL): QueryResult |
313
|
|
|
{ |
314
|
2 |
|
$this->abstractURL = $abstractURL; |
315
|
2 |
|
return $this; |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
/** |
319
|
|
|
* |
320
|
|
|
* @return string |
321
|
|
|
*/ |
322
|
|
|
public function getDefinition(): string |
323
|
|
|
{ |
324
|
|
|
return $this->definition; |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* |
329
|
|
|
* @param string $definition |
330
|
|
|
* @return QueryResult |
331
|
|
|
*/ |
332
|
2 |
|
public function setDefinition(string $definition): QueryResult |
333
|
|
|
{ |
334
|
2 |
|
$this->definition = $definition; |
335
|
2 |
|
return $this; |
336
|
|
|
} |
337
|
|
|
|
338
|
|
|
/** |
339
|
|
|
* |
340
|
|
|
* @return string |
341
|
|
|
*/ |
342
|
|
|
public function getAbstractSource(): string |
343
|
|
|
{ |
344
|
|
|
return $this->abstractSource; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/** |
348
|
|
|
* |
349
|
|
|
* @param string $abstractSource |
350
|
|
|
* @return QueryResult |
351
|
|
|
*/ |
352
|
2 |
|
public function setAbstractSource(string $abstractSource): QueryResult |
353
|
|
|
{ |
354
|
2 |
|
$this->abstractSource = $abstractSource; |
355
|
2 |
|
return $this; |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* |
360
|
|
|
* @return string |
361
|
|
|
*/ |
362
|
|
|
public function getInfobox(): string |
363
|
|
|
{ |
364
|
|
|
return $this->infobox; |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
/** |
368
|
|
|
* |
369
|
|
|
* @param string $infobox |
370
|
|
|
* @return QueryResult |
371
|
|
|
*/ |
372
|
2 |
|
public function setInfobox(string $infobox): QueryResult |
373
|
|
|
{ |
374
|
2 |
|
$this->infobox = $infobox; |
375
|
2 |
|
return $this; |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
/** |
379
|
|
|
* |
380
|
|
|
* @return string |
381
|
|
|
*/ |
382
|
|
|
public function getImage(): string |
383
|
|
|
{ |
384
|
|
|
return $this->image; |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* |
389
|
|
|
* @param string $image |
390
|
|
|
* @return QueryResult |
391
|
|
|
*/ |
392
|
2 |
|
public function setImage(string $image): QueryResult |
393
|
|
|
{ |
394
|
2 |
|
$this->image = $image; |
395
|
2 |
|
return $this; |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
/** |
399
|
|
|
* |
400
|
|
|
* @return bool |
401
|
|
|
*/ |
402
|
|
|
public function isImageIsLogo(): bool |
403
|
|
|
{ |
404
|
|
|
return $this->imageIsLogo; |
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
/** |
408
|
|
|
* |
409
|
|
|
* @param bool $imageIsLogo |
410
|
|
|
* @return QueryResult |
411
|
|
|
*/ |
412
|
2 |
|
public function setImageIsLogo(bool $imageIsLogo): QueryResult |
413
|
|
|
{ |
414
|
2 |
|
$this->imageIsLogo = $imageIsLogo; |
415
|
2 |
|
return $this; |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
/** |
419
|
|
|
* |
420
|
|
|
* @return string |
421
|
|
|
*/ |
422
|
|
|
public function getAbstract(): string |
423
|
|
|
{ |
424
|
|
|
return $this->abstract; |
425
|
|
|
} |
426
|
|
|
|
427
|
|
|
/** |
428
|
|
|
* |
429
|
|
|
* @param string $abstract |
430
|
|
|
* @return QueryResult |
431
|
|
|
*/ |
432
|
2 |
|
public function setAbstract(string $abstract): QueryResult |
433
|
|
|
{ |
434
|
2 |
|
$this->abstract = $abstract; |
435
|
2 |
|
return $this; |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
/** |
439
|
|
|
* |
440
|
|
|
* @return string |
441
|
|
|
*/ |
442
|
|
|
public function getAbstractText(): string |
443
|
|
|
{ |
444
|
|
|
return $this->abstractText; |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
/** |
448
|
|
|
* |
449
|
|
|
* @param string $abstractText |
450
|
|
|
* @return QueryResult |
451
|
|
|
*/ |
452
|
2 |
|
public function setAbstractText(string $abstractText): QueryResult |
453
|
|
|
{ |
454
|
2 |
|
$this->abstractText = $abstractText; |
455
|
2 |
|
return $this; |
456
|
|
|
} |
457
|
|
|
|
458
|
|
|
/** |
459
|
|
|
* |
460
|
|
|
* @return string |
461
|
|
|
*/ |
462
|
|
|
public function getAnswerType(): string |
463
|
|
|
{ |
464
|
|
|
return $this->answerType; |
465
|
|
|
} |
466
|
|
|
|
467
|
|
|
/** |
468
|
|
|
* |
469
|
|
|
* @param string $answerType |
470
|
|
|
* @return QueryResult |
471
|
|
|
*/ |
472
|
2 |
|
public function setAnswerType(string $answerType): QueryResult |
473
|
|
|
{ |
474
|
2 |
|
$this->answerType = $answerType; |
475
|
2 |
|
return $this; |
476
|
|
|
} |
477
|
|
|
|
478
|
|
|
/** |
479
|
|
|
* |
480
|
|
|
* @return int |
481
|
|
|
*/ |
482
|
|
|
public function getImageHeight(): int |
483
|
|
|
{ |
484
|
|
|
return $this->imageHeight; |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* |
489
|
|
|
* @param int $imageHeight |
490
|
|
|
* @return QueryResult |
491
|
|
|
*/ |
492
|
2 |
|
public function setImageHeight(int $imageHeight): QueryResult |
493
|
|
|
{ |
494
|
2 |
|
$this->imageHeight = $imageHeight; |
495
|
2 |
|
return $this; |
496
|
|
|
} |
497
|
|
|
|
498
|
|
|
/** |
499
|
|
|
* |
500
|
|
|
* @return string |
501
|
|
|
*/ |
502
|
|
|
public function getAnswer(): string |
503
|
|
|
{ |
504
|
|
|
return $this->answer; |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
/** |
508
|
|
|
* |
509
|
|
|
* @param string $answer |
510
|
|
|
* @return QueryResult |
511
|
|
|
*/ |
512
|
2 |
|
public function setAnswer($answer): QueryResult |
513
|
|
|
{ |
514
|
2 |
|
$this->answer = $answer; |
515
|
2 |
|
return $this; |
516
|
|
|
} |
517
|
|
|
|
518
|
|
|
/** |
519
|
|
|
* |
520
|
|
|
* @return array |
521
|
|
|
*/ |
522
|
2 |
|
public function getRelatedTopics(): array |
523
|
|
|
{ |
524
|
2 |
|
return $this->relatedTopics; |
525
|
|
|
} |
526
|
|
|
|
527
|
|
|
/** |
528
|
|
|
* |
529
|
|
|
* @return array |
530
|
|
|
*/ |
531
|
|
|
public function getResults(): array |
532
|
|
|
{ |
533
|
|
|
return $this->results; |
534
|
|
|
} |
535
|
|
|
|
536
|
|
|
/** |
537
|
|
|
* |
538
|
|
|
* @param Result $result |
539
|
|
|
* @return QueryResult |
540
|
|
|
*/ |
541
|
|
|
public function addResult(Result $result): QueryResult |
542
|
|
|
{ |
543
|
|
|
$this->results[] = $result; |
544
|
|
|
return $this; |
545
|
|
|
} |
546
|
|
|
|
547
|
|
|
/** |
548
|
|
|
* |
549
|
|
|
* @param RelatedTopic $topic |
550
|
|
|
* @return QueryResult |
551
|
|
|
*/ |
552
|
2 |
|
public function addRelatedTopic(RelatedTopic $topic): QueryResult |
553
|
|
|
{ |
554
|
2 |
|
$this->relatedTopics[] = $topic; |
555
|
2 |
|
return $this; |
556
|
|
|
} |
557
|
|
|
} |