Completed
Push — master ( 9528ad...369c90 )
by Michael
03:33
created
plugins/actions/twitter/Twitter.class.php 1 patch
Braces   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,12 +41,13 @@  discard block
 block discarded – undo
41 41
 		if ($bytes === false) {
42 42
 			$this->error = "Socket error: Error sending data.";
43 43
 			return false;
44
-		}
45
-		elseif ($bytes < strlen($to_send)) {
44
+		} elseif ($bytes < strlen($to_send)) {
46 45
 			$this->error = "Socket error: Could not send all data.";
47 46
 			return false;
48 47
 		}
49
-		if ($this->debug) echo "Sent:\n{$to_send}\n\n";
48
+		if ($this->debug) {
49
+			echo "Sent:\n{$to_send}\n\n";
50
+		}
50 51
 		$response = '';
51 52
 		while (!feof($fp)) {
52 53
 			$buf = fread($fp, 1024);
@@ -56,7 +57,9 @@  discard block
 block discarded – undo
56 57
 			}
57 58
 			$response .= $buf;
58 59
 		}
59
-		if ($this->debug) echo "Received:\n{$response}";
60
+		if ($this->debug) {
61
+			echo "Received:\n{$response}";
62
+		}
60 63
 		$was_error = preg_match(
61 64
 			"#" .
62 65
 			preg_quote("<error>") .
Please login to merge, or discard this patch.
plugins/actions/twitter/twitter.php 1 patch
Braces   +627 added lines, -215 removed lines patch added patch discarded remove patch
@@ -134,7 +134,9 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	public function __destruct()
136 136
 	{
137
-		if($this->curl != null) curl_close($this->curl);
137
+		if($this->curl != null) {
138
+			curl_close($this->curl);
139
+		}
138 140
 	}
139 141
 
140 142
 
@@ -147,7 +149,9 @@  discard block
 block discarded – undo
147 149
 	private function buildQuery(array $parameters)
148 150
 	{
149 151
 		// no parameters?
150
-		if(empty($parameters)) return '';
152
+		if(empty($parameters)) {
153
+			return '';
154
+		}
151 155
 
152 156
 		// encode the keys
153 157
 		$keys = self::urlencode_rfc3986(array_keys($parameters));
@@ -165,11 +169,15 @@  discard block
 block discarded – undo
165 169
 		foreach($parameters as $key => $value)
166 170
 		{
167 171
 			// sort by value
168
-			if(is_array($value)) $parameters[$key] = natsort($value);
172
+			if(is_array($value)) {
173
+				$parameters[$key] = natsort($value);
174
+			}
169 175
 		}
170 176
 
171 177
 		// process parameters
172
-		foreach($parameters as $key => $value) $chunks[] = $key .'='. str_replace('%25', '%', $value);
178
+		foreach($parameters as $key => $value) {
179
+			$chunks[] = $key .'='. str_replace('%25', '%', $value);
180
+		}
173 181
 
174 182
 		// return
175 183
 		return implode('&', $chunks);
@@ -208,7 +216,9 @@  discard block
 block discarded – undo
208 216
 		foreach($parameters as $key => $value)
209 217
 		{
210 218
 			// sort by value
211
-			if(is_array($value)) $parameters[$key] = natsort($value);
219
+			if(is_array($value)) {
220
+				$parameters[$key] = natsort($value);
221
+			}
212 222
 		}
213 223
 
214 224
 		// process queries
@@ -246,7 +256,9 @@  discard block
 block discarded – undo
246 256
 		$chunks = array();
247 257
 
248 258
 		// process queries
249
-		foreach($parameters as $key => $value) $chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key) .'="'. self::urlencode_rfc3986($value) .'"');
259
+		foreach($parameters as $key => $value) {
260
+			$chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key) .'="'. self::urlencode_rfc3986($value) .'"');
261
+		}
250 262
 
251 263
 		// build return
252 264
 		$return = 'Authorization: OAuth realm="' . $parts['scheme'] . '://' . $parts['host'] . $parts['path'] . '", ';
@@ -300,7 +312,9 @@  discard block
 block discarded – undo
300 312
 		$options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters);
301 313
 
302 314
 		// init
303
-		if($this->curl == null) $this->curl = curl_init();
315
+		if($this->curl == null) {
316
+			$this->curl = curl_init();
317
+		}
304 318
 
305 319
 		// set options
306 320
 		curl_setopt_array($this->curl, $options);
@@ -314,7 +328,9 @@  discard block
 block discarded – undo
314 328
 		$errorMessage = curl_error($this->curl);
315 329
 
316 330
 		// error?
317
-		if($errorNumber != '') throw new TwitterException($errorMessage, $errorNumber);
331
+		if($errorNumber != '') {
332
+			throw new TwitterException($errorMessage, $errorNumber);
333
+		}
318 334
 
319 335
 		// init var
320 336
 		$return = array();
@@ -349,7 +365,9 @@  discard block
 block discarded – undo
349 365
 		$expectJSON = (bool) $expectJSON;
350 366
 
351 367
 		// validate method
352
-		if(!in_array($method, $allowedMethods)) throw new TwitterException('Unknown method ('. $method .'). Allowed methods are: '. implode(', ', $allowedMethods));
368
+		if(!in_array($method, $allowedMethods)) {
369
+			throw new TwitterException('Unknown method ('. $method .'). Allowed methods are: '. implode(', ', $allowedMethods));
370
+		}
353 371
 
354 372
 		// append default parameters
355 373
 		$oauth['oauth_consumer_key'] = $this->getConsumerKey();
@@ -361,7 +379,9 @@  discard block
 block discarded – undo
361 379
 
362 380
 		// set data
363 381
 		$data = $oauth;
364
-		if(!empty($parameters)) $data = array_merge($data, $parameters);
382
+		if(!empty($parameters)) {
383
+			$data = array_merge($data, $parameters);
384
+		}
365 385
 
366 386
 		// calculate the base string
367 387
 		$base = $this->calculateBaseString(self::API_URL .'/'. $url, $method, $data);
@@ -386,9 +406,13 @@  discard block
 block discarded – undo
386 406
 
387 407
 				// set mimeType
388 408
 				$mimeType = 'application/octet-stream';
389
-				if($fileInfo['extension'] == 'jpg' || $fileInfo['extension'] == 'jpeg') $mimeType = 'image/jpeg';
390
-				elseif($fileInfo['extension'] == 'gif') $mimeType = 'image/gif';
391
-				elseif($fileInfo['extension'] == 'png') $mimeType = 'image/png';
409
+				if($fileInfo['extension'] == 'jpg' || $fileInfo['extension'] == 'jpeg') {
410
+					$mimeType = 'image/jpeg';
411
+				} elseif($fileInfo['extension'] == 'gif') {
412
+					$mimeType = 'image/gif';
413
+				} elseif($fileInfo['extension'] == 'png') {
414
+					$mimeType = 'image/png';
415
+				}
392 416
 
393 417
 				// init var
394 418
 				$content = '--'. $boundary ."\r\n";
@@ -405,16 +429,18 @@  discard block
 block discarded – undo
405 429
 			}
406 430
 
407 431
 			// no file
408
-			else $options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters);
432
+			else {
433
+				$options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters);
434
+			}
409 435
 
410 436
 			// enable post
411 437
 			$options[CURLOPT_POST] = 1;
412
-		}
413
-
414
-		else
438
+		} else
415 439
 		{
416 440
 			// add the parameters into the querystring
417
-			if(!empty($parameters)) $url .= '?'. $this->buildQuery($parameters);
441
+			if(!empty($parameters)) {
442
+				$url .= '?'. $this->buildQuery($parameters);
443
+			}
418 444
 		}
419 445
 
420 446
 		// set options
@@ -430,7 +456,9 @@  discard block
 block discarded – undo
430 456
 		$options[CURLOPT_HTTPHEADER] = $headers;
431 457
 
432 458
 		// init
433
-		if($this->curl == null) $this->curl = curl_init();
459
+		if($this->curl == null) {
460
+			$this->curl = curl_init();
461
+		}
434 462
 
435 463
 		// set options
436 464
 		curl_setopt_array($this->curl, $options);
@@ -444,7 +472,9 @@  discard block
 block discarded – undo
444 472
 		$errorMessage = curl_error($this->curl);
445 473
 
446 474
 		// we don't expext JSON, return the response
447
-		if(!$expectJSON) return $response;
475
+		if(!$expectJSON) {
476
+			return $response;
477
+		}
448 478
 
449 479
 		// replace ids with their string values, added because of some PHP-version can't handle these large values
450 480
 		$response = preg_replace('/id":(\d+)/', 'id":"\1"', $response);
@@ -502,8 +532,11 @@  discard block
 block discarded – undo
502 532
 			}
503 533
 
504 534
 			// throw exception
505
-			if(isset($json['errors'][0]['message'])) throw new TwitterException($json['errors'][0]['message']);
506
-			else throw new TwitterException('Invalid response.');
535
+			if(isset($json['errors'][0]['message'])) {
536
+				throw new TwitterException($json['errors'][0]['message']);
537
+			} else {
538
+				throw new TwitterException('Invalid response.');
539
+			}
507 540
 		}
508 541
 
509 542
 
@@ -696,8 +729,9 @@  discard block
 block discarded – undo
696 729
 	 */
697 730
 	private static function urlencode_rfc3986($value)
698 731
 	{
699
-		if(is_array($value)) return array_map(array('Twitter', 'urlencode_rfc3986'), $value);
700
-		else
732
+		if(is_array($value)) {
733
+			return array_map(array('Twitter', 'urlencode_rfc3986'), $value);
734
+		} else
701 735
 		{
702 736
 			$search = array('+', ' ', '%7E', '%');
703 737
 			$replace = array('%20', '%20', '~', '%25');
@@ -722,7 +756,9 @@  discard block
 block discarded – undo
722 756
 
723 757
 		// build parameters
724 758
 		$parameters = array();
725
-		if($skipUser) $parameters['skip_user'] = 'true';
759
+		if($skipUser) {
760
+			$parameters['skip_user'] = 'true';
761
+		}
726 762
 
727 763
 		// make the call
728 764
 		return (array) $this->doCall('statuses/public_timeline.json', $parameters);
@@ -746,11 +782,21 @@  discard block
 block discarded – undo
746 782
 
747 783
 		// build parameters
748 784
 		$parameters = array();
749
-		if($sinceId != null) $parameters['since_id'] = (string) $sinceId;
750
-		if($maxId != null) $parameters['max_id'] = (string) $maxId;
751
-		if($count != null) $parameters['count'] = (int) $count;
752
-		if($page != null) $parameters['page'] = (int) $page;
753
-		if($skipUser) $parameters['skip_user'] = 'true';
785
+		if($sinceId != null) {
786
+			$parameters['since_id'] = (string) $sinceId;
787
+		}
788
+		if($maxId != null) {
789
+			$parameters['max_id'] = (string) $maxId;
790
+		}
791
+		if($count != null) {
792
+			$parameters['count'] = (int) $count;
793
+		}
794
+		if($page != null) {
795
+			$parameters['page'] = (int) $page;
796
+		}
797
+		if($skipUser) {
798
+			$parameters['skip_user'] = 'true';
799
+		}
754 800
 
755 801
 		// make the call
756 802
 		return (array) $this->doCall('statuses/home_timeline.json', $parameters, true);
@@ -778,11 +824,21 @@  discard block
 block discarded – undo
778 824
 
779 825
 		// build parameters
780 826
 		$parameters = array();
781
-		if($sinceId != null) $parameters['since_id'] = (string) $sinceId;
782
-		if($maxId != null) $parameters['max_id'] = (string) $maxId;
783
-		if($count != null) $parameters['count'] = (int) $count;
784
-		if($page != null) $parameters['page'] = (int) $page;
785
-		if($skipUser) $parameters['skip_user'] = 'true';
827
+		if($sinceId != null) {
828
+			$parameters['since_id'] = (string) $sinceId;
829
+		}
830
+		if($maxId != null) {
831
+			$parameters['max_id'] = (string) $maxId;
832
+		}
833
+		if($count != null) {
834
+			$parameters['count'] = (int) $count;
835
+		}
836
+		if($page != null) {
837
+			$parameters['page'] = (int) $page;
838
+		}
839
+		if($skipUser) {
840
+			$parameters['skip_user'] = 'true';
841
+		}
786 842
 
787 843
 		// make the call
788 844
 		return (array) $this->doCall('statuses/friends_timeline.json', $parameters, true);
@@ -813,14 +869,30 @@  discard block
 block discarded – undo
813 869
 
814 870
 		// build parameters
815 871
 		$parameters = array();
816
-		if($id != null) $parameters['id'] = (string) $id;
817
-		if($userId != null) $parameters['user_id'] = (string) $userId;
818
-		if($screenName != null) $parameters['screen_name'] = (string) $screenName;
819
-		if($sinceId != null) $parameters['since_id'] = (string) $sinceId;
820
-		if($maxId != null) $parameters['max_id'] = (string) $maxId;
821
-		if($count != null) $parameters['count'] = (int) $count;
822
-		if($page != null) $parameters['page'] = (int) $page;
823
-		if($skipUser) $parameters['skip_user'] = 'true';
872
+		if($id != null) {
873
+			$parameters['id'] = (string) $id;
874
+		}
875
+		if($userId != null) {
876
+			$parameters['user_id'] = (string) $userId;
877
+		}
878
+		if($screenName != null) {
879
+			$parameters['screen_name'] = (string) $screenName;
880
+		}
881
+		if($sinceId != null) {
882
+			$parameters['since_id'] = (string) $sinceId;
883
+		}
884
+		if($maxId != null) {
885
+			$parameters['max_id'] = (string) $maxId;
886
+		}
887
+		if($count != null) {
888
+			$parameters['count'] = (int) $count;
889
+		}
890
+		if($page != null) {
891
+			$parameters['page'] = (int) $page;
892
+		}
893
+		if($skipUser) {
894
+			$parameters['skip_user'] = 'true';
895
+		}
824 896
 
825 897
 		// make the call
826 898
 		return (array) $this->doCall('statuses/user_timeline.json', $parameters, true);
@@ -839,14 +911,24 @@  discard block
 block discarded – undo
839 911
 	public function statusesMentions($sinceId = null, $maxId = null, $count = null, $page = null)
840 912
 	{
841 913
 		// validate
842
-		if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
914
+		if($count != null && $count > 200) {
915
+			throw new TwitterException('Count may not be greater than 200.');
916
+		}
843 917
 
844 918
 		// build parameters
845 919
 		$parameters = array();
846
-		if($sinceId != null) $parameters['since_id'] = (string) $sinceId;
847
-		if($maxId != null) $parameters['max_id'] = (string) $maxId;
848
-		if($count != null) $parameters['count'] = (int) $count;
849
-		if($page != null) $parameters['page'] = (int) $page;
920
+		if($sinceId != null) {
921
+			$parameters['since_id'] = (string) $sinceId;
922
+		}
923
+		if($maxId != null) {
924
+			$parameters['max_id'] = (string) $maxId;
925
+		}
926
+		if($count != null) {
927
+			$parameters['count'] = (int) $count;
928
+		}
929
+		if($page != null) {
930
+			$parameters['page'] = (int) $page;
931
+		}
850 932
 
851 933
 		// make the call
852 934
 		return (array) $this->doCall('statuses/mentions.json', $parameters);
@@ -865,14 +947,24 @@  discard block
 block discarded – undo
865 947
 	public function statusesRetweetedByMe($sinceId = null, $maxId = null, $count = null, $page = null)
866 948
 	{
867 949
 		// validate
868
-		if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
950
+		if($count != null && $count > 200) {
951
+			throw new TwitterException('Count may not be greater than 200.');
952
+		}
869 953
 
870 954
 		// build parameters
871 955
 		$parameters = array();
872
-		if($sinceId != null) $parameters['since_id'] = (string) $sinceId;
873
-		if($maxId != null) $parameters['max_id'] = (string) $maxId;
874
-		if($count != null) $parameters['count'] = (int) $count;
875
-		if($page != null) $parameters['page'] = (int) $page;
956
+		if($sinceId != null) {
957
+			$parameters['since_id'] = (string) $sinceId;
958
+		}
959
+		if($maxId != null) {
960
+			$parameters['max_id'] = (string) $maxId;
961
+		}
962
+		if($count != null) {
963
+			$parameters['count'] = (int) $count;
964
+		}
965
+		if($page != null) {
966
+			$parameters['page'] = (int) $page;
967
+		}
876 968
 
877 969
 		// make the call
878 970
 		return (array) $this->doCall('statuses/retweeted_by_me.json', $parameters);
@@ -891,14 +983,24 @@  discard block
 block discarded – undo
891 983
 	public function statusesRetweetedToMe($sinceId = null, $maxId = null, $count = null, $page = null)
892 984
 	{
893 985
 		// validate
894
-		if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
986
+		if($count != null && $count > 200) {
987
+			throw new TwitterException('Count may not be greater than 200.');
988
+		}
895 989
 
896 990
 		// build parameters
897 991
 		$parameters = array();
898
-		if($sinceId != null) $parameters['since_id'] = (string) $sinceId;
899
-		if($maxId != null) $parameters['max_id'] = (string) $maxId;
900
-		if($count != null) $parameters['count'] = (int) $count;
901
-		if($page != null) $parameters['page'] = (int) $page;
992
+		if($sinceId != null) {
993
+			$parameters['since_id'] = (string) $sinceId;
994
+		}
995
+		if($maxId != null) {
996
+			$parameters['max_id'] = (string) $maxId;
997
+		}
998
+		if($count != null) {
999
+			$parameters['count'] = (int) $count;
1000
+		}
1001
+		if($page != null) {
1002
+			$parameters['page'] = (int) $page;
1003
+		}
902 1004
 
903 1005
 		// make the call
904 1006
 		return (array) $this->doCall('statuses/retweeted_by_me.json', $parameters);
@@ -918,14 +1020,24 @@  discard block
 block discarded – undo
918 1020
 	public function statusesReweetsOfMe($sinceId = null, $maxId = null, $count = null, $page = null)
919 1021
 	{
920 1022
 		// validate
921
-		if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1023
+		if($count != null && $count > 200) {
1024
+			throw new TwitterException('Count may not be greater than 200.');
1025
+		}
922 1026
 
923 1027
 		// build parameters
924 1028
 		$parameters = array();
925
-		if($sinceId != null) $parameters['since_id'] = (string) $sinceId;
926
-		if($maxId != null) $parameters['max_id'] = (string) $maxId;
927
-		if($count != null) $parameters['count'] = (int) $count;
928
-		if($page != null) $parameters['page'] = (int) $page;
1029
+		if($sinceId != null) {
1030
+			$parameters['since_id'] = (string) $sinceId;
1031
+		}
1032
+		if($maxId != null) {
1033
+			$parameters['max_id'] = (string) $maxId;
1034
+		}
1035
+		if($count != null) {
1036
+			$parameters['count'] = (int) $count;
1037
+		}
1038
+		if($page != null) {
1039
+			$parameters['page'] = (int) $page;
1040
+		}
929 1041
 
930 1042
 		// make the call
931 1043
 		return (array) $this->doCall('statuses/retweets_of_me.json', $parameters);
@@ -963,11 +1075,21 @@  discard block
 block discarded – undo
963 1075
 	{
964 1076
 		// build parameters
965 1077
 		$parameters['status'] = (string) $status;
966
-		if($inReplyToStatusId != null) $parameters['in_reply_to_status_id'] = (string) $inReplyToStatusId;
967
-		if($lat != null) $parameters['lat'] = (float) $lat;
968
-		if($long != null) $parameters['long'] = (float) $long;
969
-		if($placeId != null) $parameters['place_id'] = (string) $placeId;
970
-		if($displayCoordinates) $parameters['display_coordinates'] = 'true';
1078
+		if($inReplyToStatusId != null) {
1079
+			$parameters['in_reply_to_status_id'] = (string) $inReplyToStatusId;
1080
+		}
1081
+		if($lat != null) {
1082
+			$parameters['lat'] = (float) $lat;
1083
+		}
1084
+		if($long != null) {
1085
+			$parameters['long'] = (float) $long;
1086
+		}
1087
+		if($placeId != null) {
1088
+			$parameters['place_id'] = (string) $placeId;
1089
+		}
1090
+		if($displayCoordinates) {
1091
+			$parameters['display_coordinates'] = 'true';
1092
+		}
971 1093
 
972 1094
 		// make the call
973 1095
 		return (array) $this->doCall('statuses/update.json', $parameters, true, 'POST');
@@ -1015,11 +1137,15 @@  discard block
 block discarded – undo
1015 1137
 	public function statusesRetweets($id, $count = null)
1016 1138
 	{
1017 1139
 		// validate
1018
-		if($count != null && $count > 100) throw new TwitterException('Count may not be greater than 100.');
1140
+		if($count != null && $count > 100) {
1141
+			throw new TwitterException('Count may not be greater than 100.');
1142
+		}
1019 1143
 
1020 1144
 		// build parameters
1021 1145
 		$parameters = null;
1022
-		if($count != null) $parameters['count'] = (int) $count;
1146
+		if($count != null) {
1147
+			$parameters['count'] = (int) $count;
1148
+		}
1023 1149
 
1024 1150
 		// make the call
1025 1151
 		return (array) $this->doCall('statuses/retweets/'. $id .'.json', $parameters);
@@ -1037,12 +1163,18 @@  discard block
 block discarded – undo
1037 1163
 	public function statusesIdRetweetedBy($id, $count = null, $page = null)
1038 1164
 	{
1039 1165
 		// validate
1040
-		if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1166
+		if($count != null && $count > 200) {
1167
+			throw new TwitterException('Count may not be greater than 200.');
1168
+		}
1041 1169
 
1042 1170
 		// build parameters
1043 1171
 		$parameters = null;
1044
-		if($count != null) $parameters['count'] = (int) $count;
1045
-		if($page != null) $parameters['page'] = (int) $page;
1172
+		if($count != null) {
1173
+			$parameters['count'] = (int) $count;
1174
+		}
1175
+		if($page != null) {
1176
+			$parameters['page'] = (int) $page;
1177
+		}
1046 1178
 
1047 1179
 		// make the call
1048 1180
 		return (array) $this->doCall('statuses/'. (string) $id .'/retweeted_by.json', $parameters, true);
@@ -1060,12 +1192,18 @@  discard block
 block discarded – undo
1060 1192
 	public function statusesIdRetweetedByIds($id, $count = null, $page = null)
1061 1193
 	{
1062 1194
 		// validate
1063
-		if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1195
+		if($count != null && $count > 200) {
1196
+			throw new TwitterException('Count may not be greater than 200.');
1197
+		}
1064 1198
 
1065 1199
 		// build parameters
1066 1200
 		$parameters = null;
1067
-		if($count != null) $parameters['count'] = (int) $count;
1068
-		if($page != null) $parameters['page'] = (int) $page;
1201
+		if($count != null) {
1202
+			$parameters['count'] = (int) $count;
1203
+		}
1204
+		if($page != null) {
1205
+			$parameters['page'] = (int) $page;
1206
+		}
1069 1207
 
1070 1208
 		// make the call
1071 1209
 		return (array) $this->doCall('statuses/'. (string) $id .'/retweeted_by/ids.json', $parameters, true);
@@ -1085,12 +1223,20 @@  discard block
 block discarded – undo
1085 1223
 	public function usersShow($id = null, $userId = null, $screenName = null)
1086 1224
 	{
1087 1225
 		// validate
1088
-		if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1226
+		if($id == '' && $userId == '' && $screenName == '') {
1227
+			throw new TwitterException('Specify an id or an userId or a screenName.');
1228
+		}
1089 1229
 
1090 1230
 		// build parameters
1091
-		if($id != null) $parameters['id'] = (string) $id;
1092
-		if($userId != null) $parameters['user_id'] = (string) $userId;
1093
-		if($screenName != null) $parameters['screen_name'] = (string) $screenName;
1231
+		if($id != null) {
1232
+			$parameters['id'] = (string) $id;
1233
+		}
1234
+		if($userId != null) {
1235
+			$parameters['user_id'] = (string) $userId;
1236
+		}
1237
+		if($screenName != null) {
1238
+			$parameters['screen_name'] = (string) $screenName;
1239
+		}
1094 1240
 
1095 1241
 		// make the call
1096 1242
 		return (array) $this->doCall('users/show.json', $parameters);
@@ -1112,11 +1258,17 @@  discard block
 block discarded – undo
1112 1258
 		$screenNames = (array) $screenNames;
1113 1259
 
1114 1260
 		// validate
1115
-		if(empty($userIds) && empty($screenNames)) throw new TwitterException('Specify an userId or a screenName.');
1261
+		if(empty($userIds) && empty($screenNames)) {
1262
+			throw new TwitterException('Specify an userId or a screenName.');
1263
+		}
1116 1264
 
1117 1265
 		// build parameters
1118
-		if(!empty($userIds)) $parameters['user_id'] = implode(',', $userIds);
1119
-		if(!empty($screenNames)) $parameters['screen_name'] = implode(',', $screenNames);
1266
+		if(!empty($userIds)) {
1267
+			$parameters['user_id'] = implode(',', $userIds);
1268
+		}
1269
+		if(!empty($screenNames)) {
1270
+			$parameters['screen_name'] = implode(',', $screenNames);
1271
+		}
1120 1272
 
1121 1273
 		// make the call
1122 1274
 		return (array) $this->doCall('users/lookup.json', $parameters, true);
@@ -1137,8 +1289,12 @@  discard block
 block discarded – undo
1137 1289
 	{
1138 1290
 		// build parameters
1139 1291
 		$parameters['q'] = (string) $q;
1140
-		if($perPage != null) $parameters['per_page'] = (int) $perPage;
1141
-		if($page != null) $parameters['page'] = (int) $page;
1292
+		if($perPage != null) {
1293
+			$parameters['per_page'] = (int) $perPage;
1294
+		}
1295
+		if($page != null) {
1296
+			$parameters['page'] = (int) $page;
1297
+		}
1142 1298
 
1143 1299
 		// make the call
1144 1300
 		return (array) $this->doCall('users/search.json', $parameters, true);
@@ -1188,10 +1344,18 @@  discard block
 block discarded – undo
1188 1344
 	{
1189 1345
 		// build parameters
1190 1346
 		$parameters = array();
1191
-		if($id != null) $parameters['id'] = (string) $id;
1192
-		if($userId != null) $parameters['user_id'] = (string) $userId;
1193
-		if($screenName != null) $parameters['screen_name'] = (string) $screenName;
1194
-		if($cursor != null) $parameters['cursor'] = (int) $cursor;
1347
+		if($id != null) {
1348
+			$parameters['id'] = (string) $id;
1349
+		}
1350
+		if($userId != null) {
1351
+			$parameters['user_id'] = (string) $userId;
1352
+		}
1353
+		if($screenName != null) {
1354
+			$parameters['screen_name'] = (string) $screenName;
1355
+		}
1356
+		if($cursor != null) {
1357
+			$parameters['cursor'] = (int) $cursor;
1358
+		}
1195 1359
 
1196 1360
 		// make the call
1197 1361
 		return (array) $this->doCall('statuses/friends.json', $parameters);
@@ -1212,10 +1376,18 @@  discard block
 block discarded – undo
1212 1376
 	{
1213 1377
 		// build parameters
1214 1378
 		$parameters = array();
1215
-		if($id != null) $parameters['id'] = (string) $id;
1216
-		if($userId != null) $parameters['user_id'] = (string) $userId;
1217
-		if($screenName != null) $parameters['screen_name'] = (string) $screenName;
1218
-		if($cursor != null) $parameters['cursor'] = (int) $cursor;
1379
+		if($id != null) {
1380
+			$parameters['id'] = (string) $id;
1381
+		}
1382
+		if($userId != null) {
1383
+			$parameters['user_id'] = (string) $userId;
1384
+		}
1385
+		if($screenName != null) {
1386
+			$parameters['screen_name'] = (string) $screenName;
1387
+		}
1388
+		if($cursor != null) {
1389
+			$parameters['cursor'] = (int) $cursor;
1390
+		}
1219 1391
 
1220 1392
 		// make the call
1221 1393
 		return (array) $this->doCall('statuses/followers.json', $parameters);
@@ -1246,7 +1418,9 @@  discard block
 block discarded – undo
1246 1418
 	{
1247 1419
 		// build parameters
1248 1420
 		$parameters = array();
1249
-		if($exclude != null) $parameters['exclude'] = (string) $exclude;
1421
+		if($exclude != null) {
1422
+			$parameters['exclude'] = (string) $exclude;
1423
+		}
1250 1424
 
1251 1425
 		// make the call
1252 1426
 		return (array) $this->doCall('trends/current.json', $parameters);
@@ -1264,8 +1438,12 @@  discard block
 block discarded – undo
1264 1438
 	{
1265 1439
 		// build parameters
1266 1440
 		$parameters = array();
1267
-		if($exclude != null) $parameters['exclude'] = (string) $exclude;
1268
-		if($date != null) $parameters['date'] = (string) $date;
1441
+		if($exclude != null) {
1442
+			$parameters['exclude'] = (string) $exclude;
1443
+		}
1444
+		if($date != null) {
1445
+			$parameters['date'] = (string) $date;
1446
+		}
1269 1447
 
1270 1448
 		// make the call
1271 1449
 		return (array) $this->doCall('trends/daily.json', $parameters);
@@ -1283,8 +1461,12 @@  discard block
 block discarded – undo
1283 1461
 	{
1284 1462
 		// build parameters
1285 1463
 		$parameters = array();
1286
-		if($exclude != null) $parameters['exclude'] = (string) $exclude;
1287
-		if($date != null) $parameters['date'] = (string) $date;
1464
+		if($exclude != null) {
1465
+			$parameters['exclude'] = (string) $exclude;
1466
+		}
1467
+		if($date != null) {
1468
+			$parameters['date'] = (string) $date;
1469
+		}
1288 1470
 
1289 1471
 		// make the call
1290 1472
 		return (array) $this->doCall('trends/weekly.json', $parameters);
@@ -1307,12 +1489,18 @@  discard block
 block discarded – undo
1307 1489
 		$allowedModes = array('public', 'private');
1308 1490
 
1309 1491
 		// validate
1310
-		if($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: '. implode($allowedModes) .'.');
1492
+		if($mode != null && !in_array($mode, $allowedModes)) {
1493
+			throw new TwitterException('Invalid mode (), possible values are: '. implode($allowedModes) .'.');
1494
+		}
1311 1495
 
1312 1496
 		// build parameters
1313 1497
 		$parameters['name'] = (string) $name;
1314
-		if($mode != null) $parameters['mode'] = (string) $mode;
1315
-		if($description != null) $parameters['description'] = (string) $description;
1498
+		if($mode != null) {
1499
+			$parameters['mode'] = (string) $mode;
1500
+		}
1501
+		if($description != null) {
1502
+			$parameters['description'] = (string) $description;
1503
+		}
1316 1504
 
1317 1505
 		// make the call
1318 1506
 		return (array) $this->doCall((string) $user .'/lists.json', $parameters, true, 'POST');
@@ -1329,7 +1517,9 @@  discard block
 block discarded – undo
1329 1517
 	public function userLists($user, $cursor = null)
1330 1518
 	{
1331 1519
 		$parameters = null;
1332
-		if($cursor != null) $parameters['cursor'] = (string) $cursor;
1520
+		if($cursor != null) {
1521
+			$parameters['cursor'] = (string) $cursor;
1522
+		}
1333 1523
 
1334 1524
 		// make the call
1335 1525
 		return (array) $this->doCall((string) $user .'/lists.json', $parameters, true);
@@ -1366,12 +1556,20 @@  discard block
 block discarded – undo
1366 1556
 		$allowedModes = array('public', 'private');
1367 1557
 
1368 1558
 		// validate
1369
-		if($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: '. implode($allowedModes) .'.');
1559
+		if($mode != null && !in_array($mode, $allowedModes)) {
1560
+			throw new TwitterException('Invalid mode (), possible values are: '. implode($allowedModes) .'.');
1561
+		}
1370 1562
 
1371 1563
 		// build parameters
1372
-		if($name != null) $parameters['name'] = (string) $name;
1373
-		if($mode != null) $parameters['mode'] = (string) $mode;
1374
-		if($description != null) $parameters['description'] = (string) $description;
1564
+		if($name != null) {
1565
+			$parameters['name'] = (string) $name;
1566
+		}
1567
+		if($mode != null) {
1568
+			$parameters['mode'] = (string) $mode;
1569
+		}
1570
+		if($description != null) {
1571
+			$parameters['description'] = (string) $description;
1572
+		}
1375 1573
 
1376 1574
 		// make the call
1377 1575
 		return (array) $this->doCall((string) $user .'/lists/'. (string) $id .'.json', $parameters, true, 'POST');
@@ -1392,14 +1590,24 @@  discard block
 block discarded – undo
1392 1590
 	public function userListsIdStatuses($user, $id, $sinceId = null, $maxId = null, $count = null, $page = null)
1393 1591
 	{
1394 1592
 		// validate
1395
-		if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1593
+		if($count != null && $count > 200) {
1594
+			throw new TwitterException('Count may not be greater than 200.');
1595
+		}
1396 1596
 
1397 1597
 		// build parameters
1398 1598
 		$parameters = array();
1399
-		if($sinceId != null) $parameters['since_id'] = (string) $sinceId;
1400
-		if($maxId != null) $parameters['max_id'] = (string) $maxId;
1401
-		if($count != null) $parameters['per_page'] = (int) $count;
1402
-		if($page != null) $parameters['page'] = (int) $page;
1599
+		if($sinceId != null) {
1600
+			$parameters['since_id'] = (string) $sinceId;
1601
+		}
1602
+		if($maxId != null) {
1603
+			$parameters['max_id'] = (string) $maxId;
1604
+		}
1605
+		if($count != null) {
1606
+			$parameters['per_page'] = (int) $count;
1607
+		}
1608
+		if($page != null) {
1609
+			$parameters['page'] = (int) $page;
1610
+		}
1403 1611
 
1404 1612
 		// make the call
1405 1613
 		return (array) $this->doCall((string) $user .'/lists/'. (string) $id .'/statuses.json', $parameters);
@@ -1416,7 +1624,9 @@  discard block
 block discarded – undo
1416 1624
 	public function userListsMemberships($user, $cursor = null)
1417 1625
 	{
1418 1626
 		$parameters = null;
1419
-		if($cursor != null) $parameters['cursor'] = (string) $cursor;
1627
+		if($cursor != null) {
1628
+			$parameters['cursor'] = (string) $cursor;
1629
+		}
1420 1630
 
1421 1631
 		// make the call
1422 1632
 		return (array) $this->doCall((string) $user .'/lists/memberships.json', $parameters, true);
@@ -1433,7 +1643,9 @@  discard block
 block discarded – undo
1433 1643
 	public function userListsSubscriptions($user, $cursor = null)
1434 1644
 	{
1435 1645
 		$parameters = null;
1436
-		if($cursor != null) $parameters['cursor'] = (string) $cursor;
1646
+		if($cursor != null) {
1647
+			$parameters['cursor'] = (string) $cursor;
1648
+		}
1437 1649
 
1438 1650
 		// make the call
1439 1651
 		return (array) $this->doCall((string) $user .'/lists/subscriptions.json', $parameters, true);
@@ -1452,7 +1664,9 @@  discard block
 block discarded – undo
1452 1664
 	public function userListMembers($user, $id, $cursor = null)
1453 1665
 	{
1454 1666
 		$parameters = null;
1455
-		if($cursor != null) $parameters['cursor'] = (string) $cursor;
1667
+		if($cursor != null) {
1668
+			$parameters['cursor'] = (string) $cursor;
1669
+		}
1456 1670
 
1457 1671
 		// make the call
1458 1672
 		return (array) $this->doCall((string) $user .'/'. (string) $id .'/members.json', $parameters, true);
@@ -1515,8 +1729,11 @@  discard block
 block discarded – undo
1515 1729
 		// catch exceptions
1516 1730
 		catch(TwitterException $e)
1517 1731
 		{
1518
-			if($e->getMessage() == 'The specified user is not a member of this list') return false;
1519
-			else throw $e;
1732
+			if($e->getMessage() == 'The specified user is not a member of this list') {
1733
+				return false;
1734
+			} else {
1735
+				throw $e;
1736
+			}
1520 1737
 		}
1521 1738
 	}
1522 1739
 
@@ -1533,7 +1750,9 @@  discard block
 block discarded – undo
1533 1750
 	public function userListSubscribers($user, $id, $cursor = null)
1534 1751
 	{
1535 1752
 		$parameters = null;
1536
-		if($cursor != null) $parameters['cursor'] = (string) $cursor;
1753
+		if($cursor != null) {
1754
+			$parameters['cursor'] = (string) $cursor;
1755
+		}
1537 1756
 
1538 1757
 		// make the call
1539 1758
 		return (array) $this->doCall((string) $user .'/'. (string) $id .'/subscribers.json', $parameters, true);
@@ -1590,8 +1809,11 @@  discard block
 block discarded – undo
1590 1809
 		// catch exceptions
1591 1810
 		catch(TwitterException $e)
1592 1811
 		{
1593
-			if($e->getMessage() == 'The specified user is not a subscriber of this list') return false;
1594
-			else throw $e;
1812
+			if($e->getMessage() == 'The specified user is not a subscriber of this list') {
1813
+				return false;
1814
+			} else {
1815
+				throw $e;
1816
+			}
1595 1817
 		}
1596 1818
 
1597 1819
 	}
@@ -1610,14 +1832,24 @@  discard block
 block discarded – undo
1610 1832
 	public function directMessages($sinceId = null, $maxId = null, $count = null, $page = null)
1611 1833
 	{
1612 1834
 		// validate
1613
-		if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1835
+		if($count != null && $count > 200) {
1836
+			throw new TwitterException('Count may not be greater than 200.');
1837
+		}
1614 1838
 
1615 1839
 		// build parameters
1616 1840
 		$parameters = array();
1617
-		if($sinceId != null) $parameters['since_id'] = (string) $sinceId;
1618
-		if($maxId != null) $parameters['max_id'] = (string) $maxId;
1619
-		if($count != null) $parameters['count'] = (int) $count;
1620
-		if($page != null) $parameters['page'] = (int) $page;
1841
+		if($sinceId != null) {
1842
+			$parameters['since_id'] = (string) $sinceId;
1843
+		}
1844
+		if($maxId != null) {
1845
+			$parameters['max_id'] = (string) $maxId;
1846
+		}
1847
+		if($count != null) {
1848
+			$parameters['count'] = (int) $count;
1849
+		}
1850
+		if($page != null) {
1851
+			$parameters['page'] = (int) $page;
1852
+		}
1621 1853
 
1622 1854
 		// make the call
1623 1855
 		return (array) $this->doCall('direct_messages.json', $parameters, true);
@@ -1636,14 +1868,24 @@  discard block
 block discarded – undo
1636 1868
 	public function directMessagesSent($sinceId = null, $maxId = null, $count = null, $page = null)
1637 1869
 	{
1638 1870
 		// validate
1639
-		if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1871
+		if($count != null && $count > 200) {
1872
+			throw new TwitterException('Count may not be greater than 200.');
1873
+		}
1640 1874
 
1641 1875
 		// build parameters
1642 1876
 		$parameters = array();
1643
-		if($sinceId != null) $parameters['since_id'] = (string) $sinceId;
1644
-		if($maxId != null) $parameters['max_id'] = (string) $maxId;
1645
-		if($count != null) $parameters['count'] = (int) $count;
1646
-		if($page != null) $parameters['page'] = (int) $page;
1877
+		if($sinceId != null) {
1878
+			$parameters['since_id'] = (string) $sinceId;
1879
+		}
1880
+		if($maxId != null) {
1881
+			$parameters['max_id'] = (string) $maxId;
1882
+		}
1883
+		if($count != null) {
1884
+			$parameters['count'] = (int) $count;
1885
+		}
1886
+		if($page != null) {
1887
+			$parameters['page'] = (int) $page;
1888
+		}
1647 1889
 
1648 1890
 		// make the call
1649 1891
 		return (array) $this->doCall('direct_messages/sent.json', $parameters, true);
@@ -1663,13 +1905,21 @@  discard block
 block discarded – undo
1663 1905
 	public function directMessagesNew($text, $id = null, $userId = null, $screenName = null)
1664 1906
 	{
1665 1907
 		// validate
1666
-		if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1908
+		if($id == '' && $userId == '' && $screenName == '') {
1909
+			throw new TwitterException('Specify an id or an userId or a screenName.');
1910
+		}
1667 1911
 
1668 1912
 		// build parameters
1669 1913
 		$parameters['text'] = (string) $text;
1670
-		if($id != null) $parameters['user'] = (string) $id;
1671
-		if($userId != null) $parameters['user_id'] = (string) $userId;
1672
-		if($screenName != null) $parameters['screen_name'] = (string) $screenName;
1914
+		if($id != null) {
1915
+			$parameters['user'] = (string) $id;
1916
+		}
1917
+		if($userId != null) {
1918
+			$parameters['user_id'] = (string) $userId;
1919
+		}
1920
+		if($screenName != null) {
1921
+			$parameters['screen_name'] = (string) $screenName;
1922
+		}
1673 1923
 
1674 1924
 		// make the call
1675 1925
 		return (array) $this->doCall('direct_messages/new.json', $parameters, true, 'POST');
@@ -1707,12 +1957,20 @@  discard block
 block discarded – undo
1707 1957
 	public function friendshipsCreate($id = null, $userId = null, $screenName = null, $follow = false)
1708 1958
 	{
1709 1959
 		// validate
1710
-		if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1960
+		if($id == '' && $userId == '' && $screenName == '') {
1961
+			throw new TwitterException('Specify an id or an userId or a screenName.');
1962
+		}
1711 1963
 
1712 1964
 		// build parameters
1713
-		if($id != null) $parameters['id'] = (string) $id;
1714
-		if($userId != null) $parameters['user_id'] = (string) $userId;
1715
-		if($screenName != null) $parameters['screen_name'] = (string) $screenName;
1965
+		if($id != null) {
1966
+			$parameters['id'] = (string) $id;
1967
+		}
1968
+		if($userId != null) {
1969
+			$parameters['user_id'] = (string) $userId;
1970
+		}
1971
+		if($screenName != null) {
1972
+			$parameters['screen_name'] = (string) $screenName;
1973
+		}
1716 1974
 		$parameters['follow'] = ($follow) ? 'true' : 'false';
1717 1975
 
1718 1976
 		// make the call
@@ -1732,12 +1990,20 @@  discard block
 block discarded – undo
1732 1990
 	public function friendshipsDestroy($id = null, $userId = null, $screenName = null)
1733 1991
 	{
1734 1992
 		// validate
1735
-		if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1993
+		if($id == '' && $userId == '' && $screenName == '') {
1994
+			throw new TwitterException('Specify an id or an userId or a screenName.');
1995
+		}
1736 1996
 
1737 1997
 		// build parameters
1738
-		if($id != null) $parameters['id'] = (string) $id;
1739
-		if($userId != null) $parameters['user_id'] = (string) $userId;
1740
-		if($screenName != null) $parameters['screen_name'] = (string) $screenName;
1998
+		if($id != null) {
1999
+			$parameters['id'] = (string) $id;
2000
+		}
2001
+		if($userId != null) {
2002
+			$parameters['user_id'] = (string) $userId;
2003
+		}
2004
+		if($screenName != null) {
2005
+			$parameters['screen_name'] = (string) $screenName;
2006
+		}
1741 2007
 
1742 2008
 		// make the call
1743 2009
 		return (array) $this->doCall('friendships/destroy.json', $parameters, true, 'POST');
@@ -1774,14 +2040,26 @@  discard block
 block discarded – undo
1774 2040
 	public function friendshipsShow($sourceId = null, $sourceScreenName = null, $targetId = null, $targetScreenName = null)
1775 2041
 	{
1776 2042
 		// validate
1777
-		if($sourceId == '' && $sourceScreenName == '') throw new TwitterException('Specify an sourceId or a sourceScreenName.');
1778
-		if($targetId == '' && $targetScreenName == '') throw new TwitterException('Specify an targetId or a targetScreenName.');
2043
+		if($sourceId == '' && $sourceScreenName == '') {
2044
+			throw new TwitterException('Specify an sourceId or a sourceScreenName.');
2045
+		}
2046
+		if($targetId == '' && $targetScreenName == '') {
2047
+			throw new TwitterException('Specify an targetId or a targetScreenName.');
2048
+		}
1779 2049
 
1780 2050
 		// build parameters
1781
-		if($sourceId != null) $parameters['source_id'] = (string) $sourceId;
1782
-		if($sourceScreenName != null) $parameters['source_screen_name'] = (string) $sourceScreenName;
1783
-		if($targetId != null) $parameters['target_id'] = (string) $targetId;
1784
-		if($targetScreenName != null) $parameters['target_screen_name'] = (string) $targetScreenName;
2051
+		if($sourceId != null) {
2052
+			$parameters['source_id'] = (string) $sourceId;
2053
+		}
2054
+		if($sourceScreenName != null) {
2055
+			$parameters['source_screen_name'] = (string) $sourceScreenName;
2056
+		}
2057
+		if($targetId != null) {
2058
+			$parameters['target_id'] = (string) $targetId;
2059
+		}
2060
+		if($targetScreenName != null) {
2061
+			$parameters['target_screen_name'] = (string) $targetScreenName;
2062
+		}
1785 2063
 
1786 2064
 		// make the call
1787 2065
 		return (array) $this->doCall('friendships/show.json', $parameters);
@@ -1797,7 +2075,9 @@  discard block
 block discarded – undo
1797 2075
 	public function friendshipsIncoming($cursor = null)
1798 2076
 	{
1799 2077
 		$parameters = null;
1800
-		if($cursor != null) $parameters['cursor'] = (string) $cursor;
2078
+		if($cursor != null) {
2079
+			$parameters['cursor'] = (string) $cursor;
2080
+		}
1801 2081
 
1802 2082
 		// make the call
1803 2083
 		return (array) $this->doCall('friendships/incoming.json', $parameters, true);
@@ -1813,7 +2093,9 @@  discard block
 block discarded – undo
1813 2093
 	public function friendshipsOutgoing($cursor = null)
1814 2094
 	{
1815 2095
 		$parameters = null;
1816
-		if($cursor != null) $parameters['cursor'] = (string) $cursor;
2096
+		if($cursor != null) {
2097
+			$parameters['cursor'] = (string) $cursor;
2098
+		}
1817 2099
 
1818 2100
 		// make the call
1819 2101
 		return (array) $this->doCall('friendships/outgoing.json', $parameters, true);
@@ -1833,13 +2115,23 @@  discard block
 block discarded – undo
1833 2115
 	public function friendsIds($id = null, $userId = null, $screenName = null, $cursor = null)
1834 2116
 	{
1835 2117
 		// validate
1836
-		if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2118
+		if($id == '' && $userId == '' && $screenName == '') {
2119
+			throw new TwitterException('Specify an id or an userId or a screenName.');
2120
+		}
1837 2121
 
1838 2122
 		// build parameters
1839
-		if($id != null) $parameters['id'] = (string) $id;
1840
-		if($userId != null) $parameters['user_id'] = (string) $userId;
1841
-		if($screenName != null) $parameters['screen_name'] = (string) $screenName;
1842
-		if($cursor != null) $parameters['cursor'] = (string) $cursor;
2123
+		if($id != null) {
2124
+			$parameters['id'] = (string) $id;
2125
+		}
2126
+		if($userId != null) {
2127
+			$parameters['user_id'] = (string) $userId;
2128
+		}
2129
+		if($screenName != null) {
2130
+			$parameters['screen_name'] = (string) $screenName;
2131
+		}
2132
+		if($cursor != null) {
2133
+			$parameters['cursor'] = (string) $cursor;
2134
+		}
1843 2135
 
1844 2136
 		// make the call
1845 2137
 		return (array) $this->doCall('friends/ids.json', $parameters);
@@ -1858,13 +2150,23 @@  discard block
 block discarded – undo
1858 2150
 	public function followersIds($id = null, $userId = null, $screenName = null, $cursor = null)
1859 2151
 	{
1860 2152
 		// validate
1861
-		if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2153
+		if($id == '' && $userId == '' && $screenName == '') {
2154
+			throw new TwitterException('Specify an id or an userId or a screenName.');
2155
+		}
1862 2156
 
1863 2157
 		// build parameters
1864
-		if($id != null) $parameters['id'] = (string) $id;
1865
-		if($userId != null) $parameters['user_id'] = (string) $userId;
1866
-		if($screenName != null) $parameters['screen_name'] = (string) $screenName;
1867
-		if($cursor != null) $parameters['cursor'] = (string) $cursor;
2158
+		if($id != null) {
2159
+			$parameters['id'] = (string) $id;
2160
+		}
2161
+		if($userId != null) {
2162
+			$parameters['user_id'] = (string) $userId;
2163
+		}
2164
+		if($screenName != null) {
2165
+			$parameters['screen_name'] = (string) $screenName;
2166
+		}
2167
+		if($cursor != null) {
2168
+			$parameters['cursor'] = (string) $cursor;
2169
+		}
1868 2170
 
1869 2171
 		// make the call
1870 2172
 		return (array) $this->doCall('followers/ids.json', $parameters);
@@ -1911,8 +2213,11 @@  discard block
 block discarded – undo
1911 2213
 		// catch exceptions
1912 2214
 		catch(TwitterException $e)
1913 2215
 		{
1914
-			if($e->getMessage() == 'Logged out.') return true;
1915
-			else throw $e;
2216
+			if($e->getMessage() == 'Logged out.') {
2217
+				return true;
2218
+			} else {
2219
+				throw $e;
2220
+			}
1916 2221
 		}
1917 2222
 	}
1918 2223
 
@@ -1947,14 +2252,26 @@  discard block
 block discarded – undo
1947 2252
 	public function accountUpdateProfileColors($profileBackgroundColor = null, $profileTextColor = null, $profileLinkColor = null, $profileSidebarFillColor = null, $profileSidebarBorderColor = null)
1948 2253
 	{
1949 2254
 		// validate
1950
-		if($profileBackgroundColor == '' && $profileTextColor == '' && $profileLinkColor == '' && $profileSidebarFillColor == '' && $profileSidebarBorderColor == '') throw new TwitterException('Specify a profileBackgroundColor, profileTextColor, profileLinkColor, profileSidebarFillColor or a profileSidebarBorderColor.');
2255
+		if($profileBackgroundColor == '' && $profileTextColor == '' && $profileLinkColor == '' && $profileSidebarFillColor == '' && $profileSidebarBorderColor == '') {
2256
+			throw new TwitterException('Specify a profileBackgroundColor, profileTextColor, profileLinkColor, profileSidebarFillColor or a profileSidebarBorderColor.');
2257
+		}
1951 2258
 
1952 2259
 		// build parameters
1953
-		if($profileBackgroundColor != null) $parameters['profile_background_color'] = (string) $profileBackgroundColor;
1954
-		if($profileTextColor != null) $parameters['profile_text_color'] = (string) $profileTextColor;
1955
-		if($profileLinkColor != null) $parameters['profile_link_color'] = (string) $profileLinkColor;
1956
-		if($profileSidebarFillColor != null) $parameters['profile_sidebar_fill_color'] = (string) $profileSidebarFillColor;
1957
-		if($profileSidebarBorderColor != null) $parameters['profile_sidebar_border_color'] = (string) $profileSidebarBorderColor;
2260
+		if($profileBackgroundColor != null) {
2261
+			$parameters['profile_background_color'] = (string) $profileBackgroundColor;
2262
+		}
2263
+		if($profileTextColor != null) {
2264
+			$parameters['profile_text_color'] = (string) $profileTextColor;
2265
+		}
2266
+		if($profileLinkColor != null) {
2267
+			$parameters['profile_link_color'] = (string) $profileLinkColor;
2268
+		}
2269
+		if($profileSidebarFillColor != null) {
2270
+			$parameters['profile_sidebar_fill_color'] = (string) $profileSidebarFillColor;
2271
+		}
2272
+		if($profileSidebarBorderColor != null) {
2273
+			$parameters['profile_sidebar_border_color'] = (string) $profileSidebarBorderColor;
2274
+		}
1958 2275
 
1959 2276
 		// make the call
1960 2277
 		return (array) $this->doCall('account/update_profile_colors.json', $parameters, true, 'POST');
@@ -1972,7 +2289,9 @@  discard block
 block discarded – undo
1972 2289
 		throw new TwitterException('Not implemented');
1973 2290
 
1974 2291
 		// validate
1975
-		if(!file_exists($image)) throw new TwitterException('Image ('. $image .') doesn\'t exists.');
2292
+		if(!file_exists($image)) {
2293
+			throw new TwitterException('Image ('. $image .') doesn\'t exists.');
2294
+		}
1976 2295
 
1977 2296
 		// make the call
1978 2297
 		return (array) $this->doCall('account/update_profile_image.json', null, true, 'POST', $image);
@@ -1991,10 +2310,14 @@  discard block
 block discarded – undo
1991 2310
 		throw new TwitterException('Not implemented');
1992 2311
 
1993 2312
 		// validate
1994
-		if(!file_exists($image)) throw new TwitterException('Image ('. $image .') doesn\'t exists.');
2313
+		if(!file_exists($image)) {
2314
+			throw new TwitterException('Image ('. $image .') doesn\'t exists.');
2315
+		}
1995 2316
 
1996 2317
 		// build parameters
1997
-		if($tile) $parameters['tile'] = 'true';
2318
+		if($tile) {
2319
+			$parameters['tile'] = 'true';
2320
+		}
1998 2321
 
1999 2322
 		// make the call
2000 2323
 		return (array) $this->doCall('account/update_profile_background_image.json', $parameters, true, 'POST', $image);
@@ -2014,10 +2337,18 @@  discard block
 block discarded – undo
2014 2337
 	{
2015 2338
 		// build parameters
2016 2339
 		$parameters = null;
2017
-		if($name != null) $parameters['name'] = (string) $name;
2018
-		if($url != null) $parameters['url'] = (string) $url;
2019
-		if($location != null) $parameters['location'] = (string) $location;
2020
-		if($description != null) $parameters['description'] = (string) $description;
2340
+		if($name != null) {
2341
+			$parameters['name'] = (string) $name;
2342
+		}
2343
+		if($url != null) {
2344
+			$parameters['url'] = (string) $url;
2345
+		}
2346
+		if($location != null) {
2347
+			$parameters['location'] = (string) $location;
2348
+		}
2349
+		if($description != null) {
2350
+			$parameters['description'] = (string) $description;
2351
+		}
2021 2352
 
2022 2353
 		// make the call
2023 2354
 		return (array) $this->doCall('account/update_profile.json', $parameters, true, 'POST');
@@ -2036,8 +2367,12 @@  discard block
 block discarded – undo
2036 2367
 	{
2037 2368
 		// build parameters
2038 2369
 		$parameters = null;
2039
-		if($id != null) $parameters['id'] = (string) $id;
2040
-		if($page != null) $parameters['page'] = (int) $page;
2370
+		if($id != null) {
2371
+			$parameters['id'] = (string) $id;
2372
+		}
2373
+		if($page != null) {
2374
+			$parameters['page'] = (int) $page;
2375
+		}
2041 2376
 
2042 2377
 		// make the call
2043 2378
 		return (array) $this->doCall('favorites.json', $parameters, true);
@@ -2082,12 +2417,20 @@  discard block
 block discarded – undo
2082 2417
 	public function notificationsFollow($id = null, $userId = null, $screenName = null)
2083 2418
 	{
2084 2419
 		// validate
2085
-		if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2420
+		if($id == '' && $userId == '' && $screenName == '') {
2421
+			throw new TwitterException('Specify an id or an userId or a screenName.');
2422
+		}
2086 2423
 
2087 2424
 		// build parameters
2088
-		if($id != null) $parameters['id'] = (string) $id;
2089
-		if($userId != null) $parameters['user_id'] = (string) $userId;
2090
-		if($screenName != null) $parameters['screen_name'] = (string) $screenName;
2425
+		if($id != null) {
2426
+			$parameters['id'] = (string) $id;
2427
+		}
2428
+		if($userId != null) {
2429
+			$parameters['user_id'] = (string) $userId;
2430
+		}
2431
+		if($screenName != null) {
2432
+			$parameters['screen_name'] = (string) $screenName;
2433
+		}
2091 2434
 
2092 2435
 		// make the call
2093 2436
 		return (array) $this->doCall('notifications/follow.json', $parameters, true, 'POST');
@@ -2105,12 +2448,20 @@  discard block
 block discarded – undo
2105 2448
 	public function notificationsLeave($id = null, $userId = null, $screenName = null)
2106 2449
 	{
2107 2450
 		// validate
2108
-		if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2451
+		if($id == '' && $userId == '' && $screenName == '') {
2452
+			throw new TwitterException('Specify an id or an userId or a screenName.');
2453
+		}
2109 2454
 
2110 2455
 		// build parameters
2111
-		if($id != null) $parameters['id'] = (string) $id;
2112
-		if($userId != null) $parameters['user_id'] = (string) $userId;
2113
-		if($screenName != null) $parameters['screen_name'] = (string) $screenName;
2456
+		if($id != null) {
2457
+			$parameters['id'] = (string) $id;
2458
+		}
2459
+		if($userId != null) {
2460
+			$parameters['user_id'] = (string) $userId;
2461
+		}
2462
+		if($screenName != null) {
2463
+			$parameters['screen_name'] = (string) $screenName;
2464
+		}
2114 2465
 
2115 2466
 		// make the call
2116 2467
 		return (array) $this->doCall('notifications/leave.json', $parameters, true, 'POST');
@@ -2129,12 +2480,20 @@  discard block
 block discarded – undo
2129 2480
 	public function blocksCreate($id = null, $userId = null, $screenName = null)
2130 2481
 	{
2131 2482
 		// validate
2132
-		if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2483
+		if($id == '' && $userId == '' && $screenName == '') {
2484
+			throw new TwitterException('Specify an id or an userId or a screenName.');
2485
+		}
2133 2486
 
2134 2487
 		// build parameters
2135
-		if($id != null) $parameters['id'] = (string) $id;
2136
-		if($userId != null) $parameters['user_id'] = (string) $userId;
2137
-		if($screenName != null) $parameters['screen_name'] = (string) $screenName;
2488
+		if($id != null) {
2489
+			$parameters['id'] = (string) $id;
2490
+		}
2491
+		if($userId != null) {
2492
+			$parameters['user_id'] = (string) $userId;
2493
+		}
2494
+		if($screenName != null) {
2495
+			$parameters['screen_name'] = (string) $screenName;
2496
+		}
2138 2497
 
2139 2498
 		// make the call
2140 2499
 		return (array) $this->doCall('blocks/create.json', $parameters, true, 'POST');
@@ -2152,12 +2511,20 @@  discard block
 block discarded – undo
2152 2511
 	public function blocksDestroy($id = null, $userId = null, $screenName = null)
2153 2512
 	{
2154 2513
 		// validate
2155
-		if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2514
+		if($id == '' && $userId == '' && $screenName == '') {
2515
+			throw new TwitterException('Specify an id or an userId or a screenName.');
2516
+		}
2156 2517
 
2157 2518
 		// build parameters
2158
-		if($id != null) $parameters['id'] = (string) $id;
2159
-		if($userId != null) $parameters['user_id'] = (string) $userId;
2160
-		if($screenName != null) $parameters['screen_name'] = (string) $screenName;
2519
+		if($id != null) {
2520
+			$parameters['id'] = (string) $id;
2521
+		}
2522
+		if($userId != null) {
2523
+			$parameters['user_id'] = (string) $userId;
2524
+		}
2525
+		if($screenName != null) {
2526
+			$parameters['screen_name'] = (string) $screenName;
2527
+		}
2161 2528
 
2162 2529
 		// make the call
2163 2530
 		return (array) $this->doCall('blocks/destroy.json', $parameters, true, 'POST');
@@ -2175,12 +2542,20 @@  discard block
 block discarded – undo
2175 2542
 	public function blocksExists($id = null, $userId = null, $screenName = null)
2176 2543
 	{
2177 2544
 		// validate
2178
-		if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2545
+		if($id == '' && $userId == '' && $screenName == '') {
2546
+			throw new TwitterException('Specify an id or an userId or a screenName.');
2547
+		}
2179 2548
 
2180 2549
 		// build parameters
2181
-		if($id != null) $parameters['id'] = (string) $id;
2182
-		if($userId != null) $parameters['user_id'] = (string) $userId;
2183
-		if($screenName != null) $parameters['screen_name'] = (string) $screenName;
2550
+		if($id != null) {
2551
+			$parameters['id'] = (string) $id;
2552
+		}
2553
+		if($userId != null) {
2554
+			$parameters['user_id'] = (string) $userId;
2555
+		}
2556
+		if($screenName != null) {
2557
+			$parameters['screen_name'] = (string) $screenName;
2558
+		}
2184 2559
 
2185 2560
 		try
2186 2561
 		{
@@ -2190,8 +2565,11 @@  discard block
 block discarded – undo
2190 2565
 		// catch exceptions
2191 2566
 		catch(TwitterException $e)
2192 2567
 		{
2193
-			if($e->getMessage() == 'You are not blocking this user.') return false;
2194
-			else throw $e;
2568
+			if($e->getMessage() == 'You are not blocking this user.') {
2569
+				return false;
2570
+			} else {
2571
+				throw $e;
2572
+			}
2195 2573
 		}
2196 2574
 	}
2197 2575
 
@@ -2206,7 +2584,9 @@  discard block
 block discarded – undo
2206 2584
 	{
2207 2585
 		// build parameters
2208 2586
 		$parameters = null;
2209
-		if($page != null) $parameters['page'] = (int) $page;
2587
+		if($page != null) {
2588
+			$parameters['page'] = (int) $page;
2589
+		}
2210 2590
 
2211 2591
 		// make the call
2212 2592
 		return (array) $this->doCall('blocks/blocking.json', $parameters, true);
@@ -2237,12 +2617,20 @@  discard block
 block discarded – undo
2237 2617
 	public function reportSpam($id = null, $userId = null, $screenName = null)
2238 2618
 	{
2239 2619
 		// validate
2240
-		if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2620
+		if($id == '' && $userId == '' && $screenName == '') {
2621
+			throw new TwitterException('Specify an id or an userId or a screenName.');
2622
+		}
2241 2623
 
2242 2624
 		// build parameters
2243
-		if($id != null) $parameters['id'] = (string) $id;
2244
-		if($userId != null) $parameters['user_id'] = (string) $userId;
2245
-		if($screenName != null) $parameters['screen_name'] = (string) $screenName;
2625
+		if($id != null) {
2626
+			$parameters['id'] = (string) $id;
2627
+		}
2628
+		if($userId != null) {
2629
+			$parameters['user_id'] = (string) $userId;
2630
+		}
2631
+		if($screenName != null) {
2632
+			$parameters['screen_name'] = (string) $screenName;
2633
+		}
2246 2634
 
2247 2635
 		// make the call
2248 2636
 		return (array) $this->doCall('report_spam.json', $parameters, true, 'POST');
@@ -2321,17 +2709,25 @@  discard block
 block discarded – undo
2321 2709
 		$parameters = array();
2322 2710
 
2323 2711
 		// set callback
2324
-		if($callbackURL != null) $parameters['oauth_callback'] = (string) $callbackURL;
2712
+		if($callbackURL != null) {
2713
+			$parameters['oauth_callback'] = (string) $callbackURL;
2714
+		}
2325 2715
 
2326 2716
 		// make the call
2327 2717
 		$response = $this->doOAuthCall('request_token', $parameters);
2328 2718
 
2329 2719
 		// validate
2330
-		if(!isset($response['oauth_token'], $response['oauth_token_secret'])) throw new TwitterException(implode(', ', array_keys($response)));
2720
+		if(!isset($response['oauth_token'], $response['oauth_token_secret'])) {
2721
+			throw new TwitterException(implode(', ', array_keys($response)));
2722
+		}
2331 2723
 
2332 2724
 		// set some properties
2333
-		if(isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']);
2334
-		if(isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']);
2725
+		if(isset($response['oauth_token'])) {
2726
+			$this->setOAuthToken($response['oauth_token']);
2727
+		}
2728
+		if(isset($response['oauth_token_secret'])) {
2729
+			$this->setOAuthTokenSecret($response['oauth_token_secret']);
2730
+		}
2335 2731
 
2336 2732
 		// return
2337 2733
 		return $response;
@@ -2357,8 +2753,12 @@  discard block
 block discarded – undo
2357 2753
 		$response = $this->doOAuthCall('access_token', $parameters);
2358 2754
 
2359 2755
 		// set some properties
2360
-		if(isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']);
2361
-		if(isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']);
2756
+		if(isset($response['oauth_token'])) {
2757
+			$this->setOAuthToken($response['oauth_token']);
2758
+		}
2759
+		if(isset($response['oauth_token_secret'])) {
2760
+			$this->setOAuthTokenSecret($response['oauth_token_secret']);
2761
+		}
2362 2762
 
2363 2763
 		// return
2364 2764
 		return $response;
@@ -2403,8 +2803,12 @@  discard block
 block discarded – undo
2403 2803
 	{
2404 2804
 		// build parameters
2405 2805
 		$parameters = null;
2406
-		if($lat != null) $parameters['lat_for_trends'] = (float) $lat;
2407
-		if($long != null) $parameters['long_for_trends'] = (float) $long;
2806
+		if($lat != null) {
2807
+			$parameters['lat_for_trends'] = (float) $lat;
2808
+		}
2809
+		if($long != null) {
2810
+			$parameters['long_for_trends'] = (float) $long;
2811
+		}
2408 2812
 
2409 2813
 		// make the call
2410 2814
 		return (array) $this->doCall('trends/available.json', $parameters);
@@ -2446,9 +2850,15 @@  discard block
 block discarded – undo
2446 2850
 		// build parameters
2447 2851
 		$parameters['lat'] = (float) $lat;
2448 2852
 		$parameters['long'] = (float) $long;
2449
-		if($accuracy != null) $parameters['accuracy'] = (string) $accuracy;
2450
-		if($granularity != null) $parameters['granularity'] = (string) $granularity;
2451
-		if($maxResults != null) $parameters['max_results'] = (int) $maxResults;
2853
+		if($accuracy != null) {
2854
+			$parameters['accuracy'] = (string) $accuracy;
2855
+		}
2856
+		if($granularity != null) {
2857
+			$parameters['granularity'] = (string) $granularity;
2858
+		}
2859
+		if($maxResults != null) {
2860
+			$parameters['max_results'] = (int) $maxResults;
2861
+		}
2452 2862
 
2453 2863
 		// make the call
2454 2864
 		return (array) $this->doCall('geo/reverse_geocode.json', $parameters);
@@ -2466,7 +2876,9 @@  discard block
 block discarded – undo
2466 2876
 	{
2467 2877
 		// build parameters
2468 2878
 		$parameters = null;
2469
-		if($placeId != null) $parameters['place_id'] = (string) $placeId;
2879
+		if($placeId != null) {
2880
+			$parameters['place_id'] = (string) $placeId;
2881
+		}
2470 2882
 
2471 2883
 		// make the call
2472 2884
 		return (array) $this->doCall('geo/id/'. (string) $id .'.json', $parameters);
Please login to merge, or discard this patch.