1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Queryr\Resources; |
4
|
|
|
|
5
|
|
|
use InvalidArgumentException; |
6
|
|
|
use RuntimeException; |
7
|
|
|
use Wikibase\DataModel\Entity\ItemId; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @licence GNU GPL v2+ |
11
|
|
|
* @author Jeroen De Dauw < [email protected] > |
12
|
|
|
*/ |
13
|
|
|
class ItemListElement { |
14
|
|
|
|
15
|
|
|
private $itemId; |
16
|
|
|
private $label; |
17
|
|
|
private $lastUpdate; |
18
|
|
|
private $queryrApiUrl; |
19
|
|
|
private $wikidataPageUrl; |
20
|
|
|
private $wikipediaPageUrl; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param ItemId $itemId |
24
|
|
|
* @return $this |
25
|
|
|
*/ |
26
|
3 |
|
public function setItemId( ItemId $itemId ) { |
27
|
3 |
|
$this->itemId = $itemId; |
28
|
3 |
|
return $this; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param string|null $label |
33
|
|
|
* @return $this |
34
|
|
|
* @throws InvalidArgumentException |
35
|
|
|
*/ |
36
|
1 |
|
public function setLabel( $label ) { |
37
|
1 |
|
if ( !is_string( $label ) && $label !== null ) { |
38
|
|
|
throw new InvalidArgumentException( '$label needs to be string or null' ); |
39
|
|
|
} |
40
|
|
|
|
41
|
1 |
|
$this->label = $label; |
42
|
1 |
|
return $this; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param string $lastUpdate |
47
|
|
|
* @return $this |
48
|
|
|
* @throws InvalidArgumentException |
49
|
|
|
*/ |
50
|
3 |
|
public function setLastUpdate( $lastUpdate ) { |
51
|
3 |
|
if ( !is_string( $lastUpdate ) ) { |
52
|
|
|
throw new InvalidArgumentException( '$wikidataPageUrl needs to be a string' ); |
53
|
|
|
} |
54
|
|
|
|
55
|
3 |
|
$this->lastUpdate = $lastUpdate; |
56
|
3 |
|
return $this; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param string $queryrApiUrl |
61
|
|
|
* @return $this |
62
|
|
|
* @throws InvalidArgumentException |
63
|
|
|
*/ |
64
|
3 |
|
public function setQueryrApiUrl( $queryrApiUrl ) { |
65
|
3 |
|
if ( !is_string( $queryrApiUrl ) ) { |
66
|
|
|
throw new InvalidArgumentException( '$wikidataPageUrl needs to be a string' ); |
67
|
|
|
} |
68
|
|
|
|
69
|
3 |
|
$this->queryrApiUrl = $queryrApiUrl; |
70
|
3 |
|
return $this; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @param string $wikidataPageUrl |
75
|
|
|
* @return $this |
76
|
|
|
* @throws InvalidArgumentException |
77
|
|
|
*/ |
78
|
3 |
|
public function setWikidataPageUrl( $wikidataPageUrl ) { |
79
|
3 |
|
if ( !is_string( $wikidataPageUrl ) ) { |
80
|
|
|
throw new InvalidArgumentException( '$wikidataPageUrl needs to be a string' ); |
81
|
|
|
} |
82
|
|
|
|
83
|
3 |
|
$this->wikidataPageUrl = $wikidataPageUrl; |
84
|
3 |
|
return $this; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param string|null $wikipediaPageUrl |
89
|
|
|
* @return $this |
90
|
|
|
* @throws InvalidArgumentException |
91
|
|
|
*/ |
92
|
1 |
|
public function setWikipediaPageUrl( $wikipediaPageUrl ) { |
93
|
1 |
|
if ( !is_string( $wikipediaPageUrl ) && $wikipediaPageUrl !== null ) { |
94
|
|
|
throw new InvalidArgumentException( '$wikipediaPageUrl needs to be string or null' ); |
95
|
|
|
} |
96
|
|
|
|
97
|
1 |
|
$this->wikipediaPageUrl = $wikipediaPageUrl; |
98
|
1 |
|
return $this; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return ItemId |
103
|
|
|
* @throws RuntimeException |
104
|
|
|
*/ |
105
|
2 |
|
public function getItemId() { |
106
|
2 |
|
if ( $this->itemId === null ) { |
107
|
|
|
throw new RuntimeException( 'Field not set' ); |
108
|
|
|
} |
109
|
2 |
|
return $this->itemId; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @return string |
114
|
|
|
* @throws RuntimeException |
115
|
|
|
*/ |
116
|
2 |
|
public function getLastUpdateTime() { |
117
|
2 |
|
if ( $this->lastUpdate === null ) { |
118
|
|
|
throw new RuntimeException( 'Field not set' ); |
119
|
|
|
} |
120
|
2 |
|
return $this->lastUpdate; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return string|null |
125
|
|
|
*/ |
126
|
2 |
|
public function getLabel() { |
127
|
2 |
|
return $this->label; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @return string |
132
|
|
|
* @throws RuntimeException |
133
|
|
|
*/ |
134
|
2 |
|
public function getQueryrApiUrl() { |
135
|
2 |
|
if ( $this->queryrApiUrl === null ) { |
136
|
|
|
throw new RuntimeException( 'Field not set' ); |
137
|
|
|
} |
138
|
2 |
|
return $this->queryrApiUrl; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @return string |
143
|
|
|
* @throws RuntimeException |
144
|
|
|
*/ |
145
|
2 |
|
public function getWikidataUrl() { |
146
|
2 |
|
if ( $this->wikidataPageUrl === null ) { |
147
|
|
|
throw new RuntimeException( 'Field not set' ); |
148
|
|
|
} |
149
|
2 |
|
return $this->wikidataPageUrl; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @return string|null |
154
|
|
|
*/ |
155
|
2 |
|
public function getWikipediaPageUrl() { |
156
|
2 |
|
return $this->wikipediaPageUrl; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
} |
160
|
|
|
|