1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* (c) Christian Gripp <[email protected]> |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Core23\SetlistFm\Builder; |
11
|
|
|
|
12
|
|
|
use DateTime; |
13
|
|
|
|
14
|
|
|
final class SetlistSearchBuilder |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var array |
18
|
|
|
*/ |
19
|
|
|
private $query; |
20
|
|
|
|
21
|
|
|
private function __construct() |
22
|
|
|
{ |
23
|
|
|
$this->query = []; |
24
|
|
|
|
25
|
|
|
$this->page(1); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @return SetlistSearchBuilder |
30
|
|
|
*/ |
31
|
|
|
public static function create(): self |
32
|
|
|
{ |
33
|
|
|
return new static(); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param int $page |
38
|
|
|
* |
39
|
|
|
* @return SetlistSearchBuilder |
40
|
|
|
*/ |
41
|
|
|
public function page(int $page): self |
42
|
|
|
{ |
43
|
|
|
$this->query['p'] = $page; |
44
|
|
|
|
45
|
|
|
return $this; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param string $name |
50
|
|
|
* |
51
|
|
|
* @return SetlistSearchBuilder |
52
|
|
|
*/ |
53
|
|
|
public function withArtistName(string $name): self |
54
|
|
|
{ |
55
|
|
|
$this->query['artistName'] = $name; |
56
|
|
|
|
57
|
|
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param string $mbid |
62
|
|
|
* |
63
|
|
|
* @return SetlistSearchBuilder |
64
|
|
|
*/ |
65
|
|
|
public function withArtistMbid(string $mbid): self |
66
|
|
|
{ |
67
|
|
|
$this->query['artistMbid'] = $mbid; |
68
|
|
|
|
69
|
|
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param int $tmid |
74
|
|
|
* |
75
|
|
|
* @return SetlistSearchBuilder |
76
|
|
|
*/ |
77
|
|
|
public function withArtistTmbid(int $tmid): self |
78
|
|
|
{ |
79
|
|
|
$this->query['artistTmbid'] = $tmid; |
80
|
|
|
|
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param string $name |
86
|
|
|
* |
87
|
|
|
* @return SetlistSearchBuilder |
88
|
|
|
*/ |
89
|
|
|
public function withCity(string $name): self |
90
|
|
|
{ |
91
|
|
|
$this->query['cityName'] = $name; |
92
|
|
|
|
93
|
|
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param int $id |
98
|
|
|
* |
99
|
|
|
* @return SetlistSearchBuilder |
100
|
|
|
*/ |
101
|
|
|
public function withCityId(int $id): self |
102
|
|
|
{ |
103
|
|
|
$this->query['cityId'] = $id; |
104
|
|
|
|
105
|
|
|
return $this; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param string $code |
110
|
|
|
* |
111
|
|
|
* @return SetlistSearchBuilder |
112
|
|
|
*/ |
113
|
|
|
public function withCountryCode(string $code): self |
114
|
|
|
{ |
115
|
|
|
$this->query['countryCode'] = $code; |
116
|
|
|
|
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @param DateTime $date |
122
|
|
|
* |
123
|
|
|
* @return SetlistSearchBuilder |
124
|
|
|
*/ |
125
|
|
|
public function withDate(DateTime $date): self |
126
|
|
|
{ |
127
|
|
|
$this->query['date'] = $date->format('d-m-Y'); |
128
|
|
|
|
129
|
|
|
return $this; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @param int $year |
134
|
|
|
* |
135
|
|
|
* @return SetlistSearchBuilder |
136
|
|
|
*/ |
137
|
|
|
public function withYear(int $year): self |
138
|
|
|
{ |
139
|
|
|
$this->query['year'] = $year; |
140
|
|
|
|
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @param string $eventId |
146
|
|
|
* |
147
|
|
|
* @return SetlistSearchBuilder |
148
|
|
|
* |
149
|
|
|
* @deprecated since setlist.fm API 1.0 |
150
|
|
|
*/ |
151
|
|
|
public function withLastFm(string $eventId): self |
152
|
|
|
{ |
153
|
|
|
$this->query['lastFm'] = $eventId; |
154
|
|
|
|
155
|
|
|
return $this; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @param DateTime $date |
160
|
|
|
* |
161
|
|
|
* @return SetlistSearchBuilder |
162
|
|
|
*/ |
163
|
|
|
public function withLastUpdated(DateTime $date): self |
164
|
|
|
{ |
165
|
|
|
$this->query['lastUpdated'] = $date->format('YmdHHmmss'); |
166
|
|
|
|
167
|
|
|
return $this; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @param string $name |
172
|
|
|
* |
173
|
|
|
* @return SetlistSearchBuilder |
174
|
|
|
*/ |
175
|
|
|
public function withState(string $name): self |
176
|
|
|
{ |
177
|
|
|
$this->query['state'] = $name; |
178
|
|
|
|
179
|
|
|
return $this; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @param string $code |
184
|
|
|
* |
185
|
|
|
* @return SetlistSearchBuilder |
186
|
|
|
*/ |
187
|
|
|
public function withStateCode(string $code): self |
188
|
|
|
{ |
189
|
|
|
$this->query['stateCode'] = $code; |
190
|
|
|
|
191
|
|
|
return $this; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @param string $name |
196
|
|
|
* |
197
|
|
|
* @return SetlistSearchBuilder |
198
|
|
|
*/ |
199
|
|
|
public function withTourName(string $name): self |
200
|
|
|
{ |
201
|
|
|
$this->query['tourName'] = $name; |
202
|
|
|
|
203
|
|
|
return $this; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @param string $name |
208
|
|
|
* |
209
|
|
|
* @return SetlistSearchBuilder |
210
|
|
|
*/ |
211
|
|
|
public function withVenueName(string $name): self |
212
|
|
|
{ |
213
|
|
|
$this->query['venueName'] = $name; |
214
|
|
|
|
215
|
|
|
return $this; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @param string $venueId |
220
|
|
|
* |
221
|
|
|
* @return SetlistSearchBuilder |
222
|
|
|
*/ |
223
|
|
|
public function withVenueId(string $venueId): self |
224
|
|
|
{ |
225
|
|
|
$this->query['venueId'] = $venueId; |
226
|
|
|
|
227
|
|
|
return $this; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* @return array |
232
|
|
|
*/ |
233
|
|
|
public function getQuery(): array |
234
|
|
|
{ |
235
|
|
|
return $this->query; |
236
|
|
|
} |
237
|
|
|
} |
238
|
|
|
|