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
|
|
|
* @param int $page |
30
|
|
|
* |
31
|
|
|
* @return SetlistSearchBuilder |
32
|
|
|
*/ |
33
|
|
|
public function page(int $page): self |
34
|
|
|
{ |
35
|
|
|
$this->query['p'] = $page; |
36
|
|
|
|
37
|
|
|
return $this; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param string $name |
42
|
|
|
* |
43
|
|
|
* @return SetlistSearchBuilder |
44
|
|
|
*/ |
45
|
|
|
public function withArtistName(string $name): self |
46
|
|
|
{ |
47
|
|
|
$this->query['artistName'] = $name; |
48
|
|
|
|
49
|
|
|
return $this; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param string $mbid |
54
|
|
|
* |
55
|
|
|
* @return SetlistSearchBuilder |
56
|
|
|
*/ |
57
|
|
|
public function withArtistMbid(string $mbid): self |
58
|
|
|
{ |
59
|
|
|
$this->query['artistMbid'] = $mbid; |
60
|
|
|
|
61
|
|
|
return $this; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param int $tmid |
66
|
|
|
* |
67
|
|
|
* @return SetlistSearchBuilder |
68
|
|
|
*/ |
69
|
|
|
public function withArtistTmbid(int $tmid): self |
70
|
|
|
{ |
71
|
|
|
$this->query['artistTmbid'] = $tmid; |
72
|
|
|
|
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param string $name |
78
|
|
|
* |
79
|
|
|
* @return SetlistSearchBuilder |
80
|
|
|
*/ |
81
|
|
|
public function withCity(string $name): self |
82
|
|
|
{ |
83
|
|
|
$this->query['cityName'] = $name; |
84
|
|
|
|
85
|
|
|
return $this; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param int $id |
90
|
|
|
* |
91
|
|
|
* @return SetlistSearchBuilder |
92
|
|
|
*/ |
93
|
|
|
public function withCityId(int $id): self |
94
|
|
|
{ |
95
|
|
|
$this->query['cityId'] = $id; |
96
|
|
|
|
97
|
|
|
return $this; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param string $code |
102
|
|
|
* |
103
|
|
|
* @return SetlistSearchBuilder |
104
|
|
|
*/ |
105
|
|
|
public function withCountryCode(string $code): self |
106
|
|
|
{ |
107
|
|
|
$this->query['countryCode'] = $code; |
108
|
|
|
|
109
|
|
|
return $this; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param DateTime $date |
114
|
|
|
* |
115
|
|
|
* @return SetlistSearchBuilder |
116
|
|
|
*/ |
117
|
|
|
public function withDate(DateTime $date): self |
118
|
|
|
{ |
119
|
|
|
$this->query['date'] = $date->format('d-m-Y'); |
120
|
|
|
|
121
|
|
|
return $this; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @param int $year |
126
|
|
|
* |
127
|
|
|
* @return SetlistSearchBuilder |
128
|
|
|
*/ |
129
|
|
|
public function withYear(int $year): self |
130
|
|
|
{ |
131
|
|
|
$this->query['year'] = $year; |
132
|
|
|
|
133
|
|
|
return $this; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param string $eventId |
138
|
|
|
* |
139
|
|
|
* @return SetlistSearchBuilder |
140
|
|
|
* |
141
|
|
|
* @deprecated since setlist.fm API 1.0 |
142
|
|
|
*/ |
143
|
|
|
public function withLastFm(string $eventId): self |
144
|
|
|
{ |
145
|
|
|
$this->query['lastFm'] = $eventId; |
146
|
|
|
|
147
|
|
|
return $this; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @param DateTime $date |
152
|
|
|
* |
153
|
|
|
* @return SetlistSearchBuilder |
154
|
|
|
*/ |
155
|
|
|
public function withLastUpdated(DateTime $date): self |
156
|
|
|
{ |
157
|
|
|
$this->query['lastUpdated'] = $date->format('YmdHHmmss'); |
158
|
|
|
|
159
|
|
|
return $this; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @param string $name |
164
|
|
|
* |
165
|
|
|
* @return SetlistSearchBuilder |
166
|
|
|
*/ |
167
|
|
|
public function withState(string $name): self |
168
|
|
|
{ |
169
|
|
|
$this->query['state'] = $name; |
170
|
|
|
|
171
|
|
|
return $this; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @param string $code |
176
|
|
|
* |
177
|
|
|
* @return SetlistSearchBuilder |
178
|
|
|
*/ |
179
|
|
|
public function withStateCode(string $code): self |
180
|
|
|
{ |
181
|
|
|
$this->query['stateCode'] = $code; |
182
|
|
|
|
183
|
|
|
return $this; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @param string $name |
188
|
|
|
* |
189
|
|
|
* @return SetlistSearchBuilder |
190
|
|
|
*/ |
191
|
|
|
public function withTourName(string $name): self |
192
|
|
|
{ |
193
|
|
|
$this->query['tourName'] = $name; |
194
|
|
|
|
195
|
|
|
return $this; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @param string $name |
200
|
|
|
* |
201
|
|
|
* @return SetlistSearchBuilder |
202
|
|
|
*/ |
203
|
|
|
public function withVenueName(string $name): self |
204
|
|
|
{ |
205
|
|
|
$this->query['venueName'] = $name; |
206
|
|
|
|
207
|
|
|
return $this; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* @param string $venueId |
212
|
|
|
* |
213
|
|
|
* @return SetlistSearchBuilder |
214
|
|
|
*/ |
215
|
|
|
public function withVenueId(string $venueId): self |
216
|
|
|
{ |
217
|
|
|
$this->query['venueId'] = $venueId; |
218
|
|
|
|
219
|
|
|
return $this; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* @return array |
224
|
|
|
*/ |
225
|
|
|
public function getQuery(): array |
226
|
|
|
{ |
227
|
|
|
return $this->query; |
228
|
|
|
} |
229
|
|
|
} |
230
|
|
|
|