Skip to content

Commit 5a01dda

Browse files
author
Matt Oakes
committed
Added phpdoc comments
1 parent 6044d8c commit 5a01dda

File tree

1 file changed

+96
-41
lines changed

1 file changed

+96
-41
lines changed

lastfmapi/api/event.php

Lines changed: 96 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,48 @@
11
<?php
2-
2+
/**
3+
* File that stores api calls for event api calls
4+
* @package apicalls
5+
*/
6+
/**
7+
* Allows access to the api requests relating to events
8+
* @package apicalls
9+
*/
310
class lastfmApiEvent extends lastfmApi {
4-
public $info;
11+
/**
12+
* Stores the config values set in the call
13+
* @access public
14+
* @var array
15+
*/
516
public $config;
6-
17+
/**
18+
* Stores the auth variables used in all api calls
19+
* @access private
20+
* @var array
21+
*/
722
private $auth;
23+
/**
24+
* States if the user has full authentication to use api requests that modify data
25+
* @access private
26+
* @var boolean
27+
*/
828
private $fullAuth;
929

30+
/**
31+
* @param array $auth Passes the authentication variables
32+
* @param array $fullAuth A boolean value stating if the user has full authentication or not
33+
* @param array $config An array of config variables related to caching and other features
34+
*/
1035
function __construct($auth, $fullAuth, $config) {
1136
$this->auth = $auth;
1237
$this->fullAuth = $fullAuth;
1338
$this->config = $config;
1439
}
1540

41+
/**
42+
* Set a user's attendance status for an event. (Requires full auth)
43+
* @param array $methodVars An array with the following required values: <i>eventId</i>, <i>status (0=Attending, 1=Maybe attending, 2=Not attending)</i>
44+
* @return boolean
45+
*/
1646
public function attend($methodVars) {
1747
// Only allow full authed calls
1848
if ( $this->fullAuth == TRUE ) {
@@ -48,6 +78,11 @@ public function attend($methodVars) {
4878
}
4979
}
5080

81+
/**
82+
* Get a list of attendees for an event
83+
* @param array $methodVars An array with the following required values: <i>eventId</i>
84+
* @return array
85+
*/
5186
public function getAttendees($methodVars) {
5287
// Check for required variables
5388
if ( !empty($methodVars['eventId']) ) {
@@ -58,20 +93,20 @@ public function getAttendees($methodVars) {
5893
);
5994

6095
if ( $call = $this->apiGetCall($vars) ) {
61-
$this->attendees['id'] = (string) $call->attendees['event'];
62-
$this->attendees['total'] = (string) $call->attendees['total'];
96+
$attendees['id'] = (string) $call->attendees['event'];
97+
$attendees['total'] = (string) $call->attendees['total'];
6398
$i = 0;
6499
foreach ( $call->attendees->user as $user ) {
65-
$this->attendees['attendees'][$i]['name'] = (string) $user->name;
66-
$this->attendees['attendees'][$i]['realname'] = (string) $user->realname;
67-
$this->attendees['attendees'][$i]['images']['small'] = (string) $user->image[0];
68-
$this->attendees['attendees'][$i]['images']['medium'] = (string) $user->image[1];
69-
$this->attendees['attendees'][$i]['images']['large'] = (string) $user->image[2];
70-
$this->attendees['attendees'][$i]['url'] = (string) $user->url;
100+
$attendees['attendees'][$i]['name'] = (string) $user->name;
101+
$attendees['attendees'][$i]['realname'] = (string) $user->realname;
102+
$attendees['attendees'][$i]['images']['small'] = (string) $user->image[0];
103+
$attendees['attendees'][$i]['images']['medium'] = (string) $user->image[1];
104+
$attendees['attendees'][$i]['images']['large'] = (string) $user->image[2];
105+
$attendees['attendees'][$i]['url'] = (string) $user->url;
71106
$i++;
72107
}
73108

74-
return $this->attendees;
109+
return $attendees;
75110
}
76111
else {
77112
return FALSE;
@@ -84,6 +119,11 @@ public function getAttendees($methodVars) {
84119
}
85120
}
86121

122+
/**
123+
* Get the metadata for an event on Last.fm. Includes attendance and lineup information
124+
* @param array $methodVars An array with the following required values: <i>eventId</i>
125+
* @return array
126+
*/
87127
public function getInfo($methodVars) {
88128
// Check for required variables
89129
if ( !empty($methodVars['eventId']) ) {
@@ -94,35 +134,35 @@ public function getInfo($methodVars) {
94134
);
95135

96136
if ( $call = $this->apiGetCall($vars) ) {
97-
$this->info['id'] = (string) $call->event->id;
98-
$this->info['title'] = (string) $call->event->title;
137+
$info['id'] = (string) $call->event->id;
138+
$info['title'] = (string) $call->event->title;
99139
$ii = 0;
100140
foreach ( $call->event->artists->artist as $artist ) {
101-
$this->info['artists'][$ii] = (string) $artist;
141+
$info['artists'][$ii] = (string) $artist;
102142
$ii++;
103143
}
104-
$this->info['headliner'] = (string) $call->event->artists->headliner;
105-
$this->info['venue']['name'] = (string) $call->event->venue->name;
106-
$this->info['venue']['location']['city'] = (string) $call->event->venue->location->city;
107-
$this->info['venue']['location']['country'] = (string) $call->event->venue->location->country;
108-
$this->info['venue']['location']['street'] = (string) $call->event->venue->location->street;
109-
$this->info['venue']['location']['postcode'] = (string) $call->event->venue->location->postalcode;
144+
$info['headliner'] = (string) $call->event->artists->headliner;
145+
$info['venue']['name'] = (string) $call->event->venue->name;
146+
$info['venue']['location']['city'] = (string) $call->event->venue->location->city;
147+
$info['venue']['location']['country'] = (string) $call->event->venue->location->country;
148+
$info['venue']['location']['street'] = (string) $call->event->venue->location->street;
149+
$info['venue']['location']['postcode'] = (string) $call->event->venue->location->postalcode;
110150
$geopoint = $call->event->venue->location->children('http://www.w3.org/2003/01/geo/wgs84_pos#');
111-
$this->info['venue']['location']['geopoint']['lat'] = (string) $geopoint->point->lat;
112-
$this->info['venue']['location']['geopoint']['long'] = (string) $geopoint->point->long;
113-
$this->info['venue']['location']['timezone'] = (string) $call->event->venue->location->timezone;
114-
$this->info['venue']['url'] = (string) $call->venue->url;
115-
$this->info['startdate'] = strtotime(trim((string) $call->event->startDate));
116-
$this->info['description'] = (string) $call->event->description;
117-
$this->info['image']['small'] = (string) $call->event->image[0];
118-
$this->info['image']['medium'] = (string) $call->event->image[1];
119-
$this->info['image']['large'] = (string) $call->event->image[2];
120-
$this->info['attendance'] = (string) $call->event->attendance;
121-
$this->info['reviews'] = (string) $call->event->reviews;
122-
$this->info['tag'] = (string) $call->event->tag;
123-
$this->info['url'] = (string) $call->event->url;
151+
$info['venue']['location']['geopoint']['lat'] = (string) $geopoint->point->lat;
152+
$info['venue']['location']['geopoint']['long'] = (string) $geopoint->point->long;
153+
$info['venue']['location']['timezone'] = (string) $call->event->venue->location->timezone;
154+
$info['venue']['url'] = (string) $call->venue->url;
155+
$info['startdate'] = strtotime(trim((string) $call->event->startDate));
156+
$info['description'] = (string) $call->event->description;
157+
$info['image']['small'] = (string) $call->event->image[0];
158+
$info['image']['medium'] = (string) $call->event->image[1];
159+
$info['image']['large'] = (string) $call->event->image[2];
160+
$info['attendance'] = (string) $call->event->attendance;
161+
$info['reviews'] = (string) $call->event->reviews;
162+
$info['tag'] = (string) $call->event->tag;
163+
$info['url'] = (string) $call->event->url;
124164

125-
return $this->info;
165+
return $info;
126166
}
127167
else {
128168
return FALSE;
@@ -135,6 +175,11 @@ public function getInfo($methodVars) {
135175
}
136176
}
137177

178+
/**
179+
* Get shouts for this event
180+
* @param array $methodVars An array with the following required values: <i>eventId</i>
181+
* @return array
182+
*/
138183
public function getShouts($methodVars) {
139184
// Check for required variables
140185
if ( !empty($methodVars['eventId']) ) {
@@ -145,17 +190,17 @@ public function getShouts($methodVars) {
145190
);
146191

147192
if ( $call = $this->apiGetCall($vars) ) {
148-
$this->shouts['id'] = (string) $call->shouts['event'];
149-
$this->shouts['total'] = (string) $call->shouts['total'];
193+
$shouts['id'] = (string) $call->shouts['event'];
194+
$shouts['total'] = (string) $call->shouts['total'];
150195
$i = 0;
151196
foreach ( $call->shouts->shout as $shout ) {
152-
$this->shouts['shouts'][$i]['body'] = (string) $shout->body;
153-
$this->shouts['shouts'][$i]['author'] = (string) $shout->author;
154-
$this->shouts['shouts'][$i]['date'] = strtotime((string) $shout->date);
197+
$shouts['shouts'][$i]['body'] = (string) $shout->body;
198+
$shouts['shouts'][$i]['author'] = (string) $shout->author;
199+
$shouts['shouts'][$i]['date'] = strtotime((string) $shout->date);
155200
$i++;
156201
}
157202

158-
return $this->shouts;
203+
return $shouts;
159204
}
160205
else {
161206
return FALSE;
@@ -168,6 +213,11 @@ public function getShouts($methodVars) {
168213
}
169214
}
170215

216+
/**
217+
* Share an event with one or more Last.fm users or other friends. (Requires full auth)
218+
* @param array $methodVars An array with the following required values: <i>eventId</i>, <i>recipient</i> and option value: <i>message</i>
219+
* @return boolean
220+
*/
171221
public function share($methodVars) {
172222
// Only allow full authed calls
173223
if ( $this->fullAuth == TRUE ) {
@@ -206,6 +256,11 @@ public function share($methodVars) {
206256
}
207257
}
208258

259+
/**
260+
* Shout in this event's shoutbox (Requires full auth)
261+
* @param array $methodVars An array with the following required values: <i>eventId</i>, <i>message</i>
262+
* @return boolean
263+
*/
209264
public function shout($methodVars) {
210265
// Only allow full authed calls
211266
if ( $this->fullAuth == TRUE ) {

0 commit comments

Comments
 (0)