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