Completed
Branch master (402923)
by Michael
03:40
created
rss.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
 @$xoopsLogger->activated = false;
29 29
 
30 30
 if (!references_utils::getModuleOption('use_rss')) {
31
-    exit(_ERRORS);
31
+	exit(_ERRORS);
32 32
 }
33 33
 
34 34
 if (function_exists('mb_http_output')) {
35
-    mb_http_output('pass');
35
+	mb_http_output('pass');
36 36
 }
37 37
 $charset = 'utf-8';
38 38
 header('Content-Type:text/xml; charset=' . $charset);
@@ -42,52 +42,52 @@  discard block
 block discarded – undo
42 42
 $tpl->xoops_setCacheTime(references_utils::getModuleOption('rss_cache_time'));    // Temps de cache en secondes
43 43
 $uid = references_utils::getCurrentUserID();
44 44
 if (!$tpl->is_cached('db:references_rss.tpl', $uid)) {
45
-    $categoryTitle = '';
46
-    global $xoopsConfig;
47
-    $sitename = htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES);
48
-    $email    = $xoopsConfig['adminmail'];
49
-    $slogan   = htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES);
45
+	$categoryTitle = '';
46
+	global $xoopsConfig;
47
+	$sitename = htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES);
48
+	$email    = $xoopsConfig['adminmail'];
49
+	$slogan   = htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES);
50 50
 
51
-    $tpl->assign('charset', $charset);
52
-    $tpl->assign('channel_title', xoops_utf8_encode($sitename));
53
-    $tpl->assign('channel_link', XOOPS_URL . '/');
54
-    $tpl->assign('channel_desc', xoops_utf8_encode($slogan));
55
-    $tpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss'));
56
-    $tpl->assign('channel_webmaster', xoops_utf8_encode($email));
57
-    $tpl->assign('channel_editor', xoops_utf8_encode($email));
58
-    $tpl->assign('channel_category', xoops_utf8_encode($categoryTitle));
59
-    $tpl->assign('channel_generator', xoops_utf8_encode(references_utils::getModuleName()));
60
-    $tpl->assign('channel_language', _LANGCODE);
61
-    $tpl->assign('image_url', XOOPS_URL . '/assets/images/logo.gif');
62
-    $dimention = getimagesize(XOOPS_ROOT_PATH . '/assets/images/logo.gif');
63
-    if (empty($dimention[0])) {
64
-        $width = 88;
65
-    } else {
66
-        $width = ($dimention[0] > 144) ? 144 : $dimention[0];
67
-    }
68
-    if (empty($dimention[1])) {
69
-        $height = 31;
70
-    } else {
71
-        $height = ($dimention[1] > 400) ? 400 : $dimention[1];
72
-    }
73
-    $tpl->assign('image_width', $width);
74
-    $tpl->assign('image_height', $height);
75
-    $start = 0;
76
-    $limit = references_utils::getModuleOption('nb_perpage');
77
-    $items = array();
51
+	$tpl->assign('charset', $charset);
52
+	$tpl->assign('channel_title', xoops_utf8_encode($sitename));
53
+	$tpl->assign('channel_link', XOOPS_URL . '/');
54
+	$tpl->assign('channel_desc', xoops_utf8_encode($slogan));
55
+	$tpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss'));
56
+	$tpl->assign('channel_webmaster', xoops_utf8_encode($email));
57
+	$tpl->assign('channel_editor', xoops_utf8_encode($email));
58
+	$tpl->assign('channel_category', xoops_utf8_encode($categoryTitle));
59
+	$tpl->assign('channel_generator', xoops_utf8_encode(references_utils::getModuleName()));
60
+	$tpl->assign('channel_language', _LANGCODE);
61
+	$tpl->assign('image_url', XOOPS_URL . '/assets/images/logo.gif');
62
+	$dimention = getimagesize(XOOPS_ROOT_PATH . '/assets/images/logo.gif');
63
+	if (empty($dimention[0])) {
64
+		$width = 88;
65
+	} else {
66
+		$width = ($dimention[0] > 144) ? 144 : $dimention[0];
67
+	}
68
+	if (empty($dimention[1])) {
69
+		$height = 31;
70
+	} else {
71
+		$height = ($dimention[1] > 400) ? 400 : $dimention[1];
72
+	}
73
+	$tpl->assign('image_width', $width);
74
+	$tpl->assign('image_height', $height);
75
+	$start = 0;
76
+	$limit = references_utils::getModuleOption('nb_perpage');
77
+	$items = array();
78 78
 
79
-    $items = $h_references_articles->getRecentArticles($start, $limit);
80
-    foreach ($items as $item) {
81
-        $titre       = htmlspecialchars($item->getVar('article_title', 'n'), ENT_QUOTES);
82
-        $description = htmlspecialchars($item->getVar('article_text'), ENT_QUOTES);
83
-        $link        = REFERENCES_URL;
84
-        $tpl->append('items', array(
85
-            'title'       => xoops_utf8_encode($titre),
86
-            'link'        => $link,
87
-            'guid'        => $link,
88
-            'pubdate'     => formatTimestamp($item->getVar('article_timestamp'), 'rss'),
89
-            'description' => xoops_utf8_encode($description)
90
-        ));
91
-    }
79
+	$items = $h_references_articles->getRecentArticles($start, $limit);
80
+	foreach ($items as $item) {
81
+		$titre       = htmlspecialchars($item->getVar('article_title', 'n'), ENT_QUOTES);
82
+		$description = htmlspecialchars($item->getVar('article_text'), ENT_QUOTES);
83
+		$link        = REFERENCES_URL;
84
+		$tpl->append('items', array(
85
+			'title'       => xoops_utf8_encode($titre),
86
+			'link'        => $link,
87
+			'guid'        => $link,
88
+			'pubdate'     => formatTimestamp($item->getVar('article_timestamp'), 'rss'),
89
+			'description' => xoops_utf8_encode($description)
90
+		));
91
+	}
92 92
 }
93 93
 $tpl->display('db:references_rss.tpl', $uid);
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 /**
23 23
  * Flux RSS
24 24
  */
25
-require __DIR__ . '/header.php';
26
-require_once XOOPS_ROOT_PATH . '/class/template.php';
25
+require __DIR__.'/header.php';
26
+require_once XOOPS_ROOT_PATH.'/class/template.php';
27 27
 error_reporting(0);
28 28
 @$xoopsLogger->activated = false;
29 29
 
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
     mb_http_output('pass');
36 36
 }
37 37
 $charset = 'utf-8';
38
-header('Content-Type:text/xml; charset=' . $charset);
38
+header('Content-Type:text/xml; charset='.$charset);
39 39
 
40 40
 $tpl = new XoopsTpl();
41
-$tpl->xoops_setCaching(2);                                                        // 1 = Cache global, 2 = Cache individuel (par template)
42
-$tpl->xoops_setCacheTime(references_utils::getModuleOption('rss_cache_time'));    // Temps de cache en secondes
41
+$tpl->xoops_setCaching(2); // 1 = Cache global, 2 = Cache individuel (par template)
42
+$tpl->xoops_setCacheTime(references_utils::getModuleOption('rss_cache_time')); // Temps de cache en secondes
43 43
 $uid = references_utils::getCurrentUserID();
44 44
 if (!$tpl->is_cached('db:references_rss.tpl', $uid)) {
45 45
     $categoryTitle = '';
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     $tpl->assign('charset', $charset);
52 52
     $tpl->assign('channel_title', xoops_utf8_encode($sitename));
53
-    $tpl->assign('channel_link', XOOPS_URL . '/');
53
+    $tpl->assign('channel_link', XOOPS_URL.'/');
54 54
     $tpl->assign('channel_desc', xoops_utf8_encode($slogan));
55 55
     $tpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss'));
56 56
     $tpl->assign('channel_webmaster', xoops_utf8_encode($email));
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
     $tpl->assign('channel_category', xoops_utf8_encode($categoryTitle));
59 59
     $tpl->assign('channel_generator', xoops_utf8_encode(references_utils::getModuleName()));
60 60
     $tpl->assign('channel_language', _LANGCODE);
61
-    $tpl->assign('image_url', XOOPS_URL . '/assets/images/logo.gif');
62
-    $dimention = getimagesize(XOOPS_ROOT_PATH . '/assets/images/logo.gif');
61
+    $tpl->assign('image_url', XOOPS_URL.'/assets/images/logo.gif');
62
+    $dimention = getimagesize(XOOPS_ROOT_PATH.'/assets/images/logo.gif');
63 63
     if (empty($dimention[0])) {
64 64
         $width = 88;
65 65
     } else {
Please login to merge, or discard this patch.
class/lite.php 2 patches
Indentation   +836 added lines, -836 removed lines patch added patch discarded remove patch
@@ -28,840 +28,840 @@
 block discarded – undo
28 28
 class references_Cache_Lite
29 29
 {
30 30
 
31
-    // --- Private properties ---
32
-
33
-    /**
34
-     * Directory where to put the cache files
35
-     * (make sure to add a trailing slash)
36
-     *
37
-     * @var string $_cacheDir
38
-     */
39
-    public $_cacheDir = '/tmp/';
40
-
41
-    /**
42
-     * Enable / disable caching
43
-     *
44
-     * (can be very usefull for the debug of cached scripts)
45
-     *
46
-     * @var boolean $_caching
47
-     */
48
-    public $_caching = true;
49
-
50
-    /**
51
-     * Cache lifetime (in seconds)
52
-     *
53
-     * If null, the cache is valid forever.
54
-     *
55
-     * @var int $_lifeTime
56
-     */
57
-    public $_lifeTime = 3600;
58
-
59
-    /**
60
-     * Enable / disable fileLocking
61
-     *
62
-     * (can avoid cache corruption under bad circumstances)
63
-     *
64
-     * @var boolean $_fileLocking
65
-     */
66
-    public $_fileLocking = true;
67
-
68
-    /**
69
-     * Timestamp of the last valid cache
70
-     *
71
-     * @var int $_refreshTime
72
-     */
73
-    public $_refreshTime;
74
-
75
-    /**
76
-     * File name (with path)
77
-     *
78
-     * @var string $_file
79
-     */
80
-    public $_file;
81
-
82
-    /**
83
-     * File name (without path)
84
-     *
85
-     * @var string $_fileName
86
-     */
87
-    public $_fileName;
88
-
89
-    /**
90
-     * Enable / disable write control (the cache is read just after writing to detect corrupt entries)
91
-     *
92
-     * Enable write control will lightly slow the cache writing but not the cache reading
93
-     * Write control can detect some corrupt cache files but maybe it's not a perfect control
94
-     *
95
-     * @var boolean $_writeControl
96
-     */
97
-    public $_writeControl = true;
98
-
99
-    /**
100
-     * Enable / disable read control
101
-     *
102
-     * If enabled, a control key is embeded in cache file and this key is compared with the one
103
-     * calculated after the reading.
104
-     *
105
-     * @var boolean $_writeControl
106
-     */
107
-    public $_readControl = true;
108
-
109
-    /**
110
-     * Type of read control (only if read control is enabled)
111
-     *
112
-     * Available values are :
113
-     * 'md5' for a md5 hash control (best but slowest)
114
-     * 'crc32' for a crc32 hash control (lightly less safe but faster, better choice)
115
-     * 'strlen' for a length only test (fastest)
116
-     *
117
-     * @var boolean $_readControlType
118
-     */
119
-    public $_readControlType = 'crc32';
120
-
121
-    /**
122
-     * Pear error mode (when raiseError is called)
123
-     *
124
-     * (see PEAR doc)
125
-     *
126
-     * @see setToDebug()
127
-     * @var int $_pearErrorMode
128
-     */
129
-    public $_pearErrorMode = REFERENCES_CACHE_LITE_ERROR_RETURN;
130
-
131
-    /**
132
-     * Current cache id
133
-     *
134
-     * @var string $_id
135
-     */
136
-    public $_id;
137
-
138
-    /**
139
-     * Current cache group
140
-     *
141
-     * @var string $_group
142
-     */
143
-    public $_group;
144
-
145
-    /**
146
-     * Enable / Disable "Memory Caching"
147
-     *
148
-     * NB : There is no lifetime for memory caching !
149
-     *
150
-     * @var boolean $_memoryCaching
151
-     */
152
-    public $_memoryCaching = false;
153
-
154
-    /**
155
-     * Enable / Disable "Only Memory Caching"
156
-     * (be carefull, memory caching is "beta quality")
157
-     *
158
-     * @var boolean $_onlyMemoryCaching
159
-     */
160
-    public $_onlyMemoryCaching = false;
161
-
162
-    /**
163
-     * Memory caching array
164
-     *
165
-     * @var array $_memoryCachingArray
166
-     */
167
-    public $_memoryCachingArray = array();
168
-
169
-    /**
170
-     * Memory caching counter
171
-     *
172
-     * @var int $memoryCachingCounter
173
-     */
174
-    public $_memoryCachingCounter = 0;
175
-
176
-    /**
177
-     * Memory caching limit
178
-     *
179
-     * @var int $memoryCachingLimit
180
-     */
181
-    public $_memoryCachingLimit = 1000;
182
-
183
-    /**
184
-     * File Name protection
185
-     *
186
-     * if set to true, you can use any cache id or group name
187
-     * if set to false, it can be faster but cache ids and group names
188
-     * will be used directly in cache file names so be carefull with
189
-     * special characters...
190
-     *
191
-     * @var boolean $fileNameProtection
192
-     */
193
-    public $_fileNameProtection = true;
194
-
195
-    /**
196
-     * Enable / disable automatic serialization
197
-     *
198
-     * it can be used to save directly datas which aren't strings
199
-     * (but it's slower)
200
-     *
201
-     * @var boolean $_serialize
202
-     */
203
-    public $_automaticSerialization = false;
204
-
205
-    /**
206
-     * Disable / Tune the automatic cleaning process
207
-     *
208
-     * The automatic cleaning process destroy too old (for the given life time)
209
-     * cache files when a new cache file is written.
210
-     * 0               => no automatic cache cleaning
211
-     * 1               => systematic cache cleaning
212
-     * x (integer) > 1 => automatic cleaning randomly 1 times on x cache write
213
-     *
214
-     * @var int $_automaticCleaning
215
-     */
216
-    public $_automaticCleaningFactor = 0;
217
-
218
-    /**
219
-     * Nested directory level
220
-     *
221
-     * Set the hashed directory structure level. 0 means "no hashed directory
222
-     * structure", 1 means "one level of directory", 2 means "two levels"...
223
-     * This option can speed up Cache_Lite only when you have many thousands of
224
-     * cache file. Only specific benchs can help you to choose the perfect value
225
-     * for you. Maybe, 1 or 2 is a good start.
226
-     *
227
-     * @var int $_hashedDirectoryLevel
228
-     */
229
-    public $_hashedDirectoryLevel = 0;
230
-
231
-    /**
232
-     * Umask for hashed directory structure
233
-     *
234
-     * @var int $_hashedDirectoryUmask
235
-     */
236
-    public $_hashedDirectoryUmask = 0700;
237
-
238
-    /**
239
-     * API break for error handling in REFERENCES_CACHE_LITE_ERROR_RETURN mode
240
-     *
241
-     * In REFERENCES_CACHE_LITE_ERROR_RETURN mode, error handling was not good because
242
-     * for example save() method always returned a boolean (a PEAR_Error object
243
-     * would be better in REFERENCES_CACHE_LITE_ERROR_RETURN mode). To correct this without
244
-     * breaking the API, this option (false by default) can change this handling.
245
-     *
246
-     * @var boolean
247
-     */
248
-    public $_errorHandlingAPIBreak = false;
249
-
250
-    // --- Public methods ---
251
-
252
-    /**
253
-     * Constructor
254
-     *
255
-     * $options is an assoc. Available options are :
256
-     * $options = array(
257
-     *     'cacheDir' => directory where to put the cache files (string) ,
258
-     *     'caching' => enable / disable caching (boolean) ,
259
-     *     'lifeTime' => cache lifetime in seconds (int) ,
260
-     *     'fileLocking' => enable / disable fileLocking (boolean) ,
261
-     *     'writeControl' => enable / disable write control (boolean) ,
262
-     *     'readControl' => enable / disable read control (boolean) ,
263
-     *     'readControlType' => type of read control 'crc32', 'md5', 'strlen' (string) ,
264
-     *     'pearErrorMode' => pear error mode (when raiseError is called) (cf PEAR doc) (int) ,
265
-     *     'memoryCaching' => enable / disable memory caching (boolean) ,
266
-     *     'onlyMemoryCaching' => enable / disable only memory caching (boolean) ,
267
-     *     'memoryCachingLimit' => max nbr of records to store into memory caching (int) ,
268
-     *     'fileNameProtection' => enable / disable automatic file name protection (boolean) ,
269
-     *     'automaticSerialization' => enable / disable automatic serialization (boolean) ,
270
-     *     'automaticCleaningFactor' => distable / tune automatic cleaning process (int) ,
271
-     *     'hashedDirectoryLevel' => level of the hashed directory system (int) ,
272
-     *     'hashedDirectoryUmask' => umask for hashed directory structure (int) ,
273
-     *     'errorHandlingAPIBreak' => API break for better error handling ? (boolean)
274
-     * );
275
-     *
276
-     * @param array $options options
277
-     * @access public
278
-     */
279
-    public function __construct($options = array(null))
280
-    {
281
-        foreach ($options as $key => $value) {
282
-            $this->setOption($key, $value);
283
-        }
284
-    }
285
-
286
-    /**
287
-     * Generic way to set a Cache_Lite option
288
-     *
289
-     * see Cache_Lite constructor for available options
290
-     *
291
-     * @var string $name  name of the option
292
-     * @var mixed  $value value of the option
293
-     * @access public
294
-     */
295
-    public function setOption($name, $value)
296
-    {
297
-        $availableOptions = array(
298
-            'errorHandlingAPIBreak',
299
-            'hashedDirectoryUmask',
300
-            'hashedDirectoryLevel',
301
-            'automaticCleaningFactor',
302
-            'automaticSerialization',
303
-            'fileNameProtection',
304
-            'memoryCaching',
305
-            'onlyMemoryCaching',
306
-            'memoryCachingLimit',
307
-            'cacheDir',
308
-            'caching',
309
-            'lifeTime',
310
-            'fileLocking',
311
-            'writeControl',
312
-            'readControl',
313
-            'readControlType',
314
-            'pearErrorMode'
315
-        );
316
-        if (in_array($name, $availableOptions)) {
317
-            $property        = '_' . $name;
318
-            $this->$property = $value;
319
-        }
320
-    }
321
-
322
-    /**
323
-     * Test if a cache is available and (if yes) return it
324
-     *
325
-     * @param string  $id                     cache id
326
-     * @param string  $group                  name of the cache group
327
-     * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
328
-     * @return string data of the cache (else : false)
329
-     * @access public
330
-     */
331
-    public function get($id, $group = 'default', $doNotTestCacheValidity = false)
332
-    {
333
-        $this->_id    = $id;
334
-        $this->_group = $group;
335
-        $data         = false;
336
-        if ($this->_caching) {
337
-            $this->_setRefreshTime();
338
-            $this->_setFileName($id, $group);
339
-            clearstatcache();
340
-            if ($this->_memoryCaching) {
341
-                if (isset($this->_memoryCachingArray[$this->_file])) {
342
-                    if ($this->_automaticSerialization) {
343
-                        return unserialize($this->_memoryCachingArray[$this->_file]);
344
-                    }
345
-
346
-                    return $this->_memoryCachingArray[$this->_file];
347
-                }
348
-                if ($this->_onlyMemoryCaching) {
349
-                    return false;
350
-                }
351
-            }
352
-            if ($doNotTestCacheValidity || is_null($this->_refreshTime)) {
353
-                if (file_exists($this->_file)) {
354
-                    $data = $this->_read();
355
-                }
356
-            } else {
357
-                if (file_exists($this->_file) && (@filemtime($this->_file) > $this->_refreshTime)) {
358
-                    $data = $this->_read();
359
-                }
360
-            }
361
-            if ($data && $this->_memoryCaching) {
362
-                $this->_memoryCacheAdd($data);
363
-            }
364
-            if ($this->_automaticSerialization && is_string($data)) {
365
-                $data = unserialize($data);
366
-            }
367
-
368
-            return $data;
369
-        }
370
-
371
-        return false;
372
-    }
373
-
374
-    /**
375
-     * Save some data in a cache file
376
-     *
377
-     * @param string $data  data to put in cache (can be another type than strings if automaticSerialization is on)
378
-     * @param string $id    cache id
379
-     * @param string $group name of the cache group
380
-     * @return boolean true if no problem (else : false or a PEAR_Error object)
381
-     * @access public
382
-     */
383
-    public function save($data, $id = null, $group = 'default')
384
-    {
385
-        if ($this->_caching) {
386
-            if ($this->_automaticSerialization) {
387
-                $data = serialize($data);
388
-            }
389
-            if (isset($id)) {
390
-                $this->_setFileName($id, $group);
391
-            }
392
-            if ($this->_memoryCaching) {
393
-                $this->_memoryCacheAdd($data);
394
-                if ($this->_onlyMemoryCaching) {
395
-                    return true;
396
-                }
397
-            }
398
-            if ($this->_automaticCleaningFactor > 0 && ($this->_automaticCleaningFactor == 1 || mt_rand(1, $this->_automaticCleaningFactor) == 1)) {
399
-                $this->clean(false, 'old');
400
-            }
401
-            if ($this->_writeControl) {
402
-                $res = $this->_writeAndControl($data);
403
-                if (is_bool($res)) {
404
-                    if ($res) {
405
-                        return true;
406
-                    }
407
-                    // if $res if false, we need to invalidate the cache
408
-                    @touch($this->_file, time() - 2 * abs($this->_lifeTime));
409
-
410
-                    return false;
411
-                }
412
-            } else {
413
-                $res = $this->_write($data);
414
-            }
415
-            if (is_object($res)) {
416
-                // $res is a PEAR_Error object
417
-                if (!$this->_errorHandlingAPIBreak) {
418
-                    return false; // we return false (old API)
419
-                }
420
-            }
421
-
422
-            return $res;
423
-        }
424
-
425
-        return false;
426
-    }
427
-
428
-    /**
429
-     * Remove a cache file
430
-     *
431
-     * @param string  $id                cache id
432
-     * @param string  $group             name of the cache group
433
-     * @param boolean $checkbeforeunlink check if file exists before removing it
434
-     * @return boolean true if no problem
435
-     * @access public
436
-     */
437
-    public function remove($id, $group = 'default', $checkbeforeunlink = false)
438
-    {
439
-        $this->_setFileName($id, $group);
440
-        if ($this->_memoryCaching) {
441
-            if (isset($this->_memoryCachingArray[$this->_file])) {
442
-                unset($this->_memoryCachingArray[$this->_file]);
443
-                --$this->_memoryCachingCounter;
444
-            }
445
-            if ($this->_onlyMemoryCaching) {
446
-                return true;
447
-            }
448
-        }
449
-        if ($checkbeforeunlink) {
450
-            if (!file_exists($this->_file)) {
451
-                return true;
452
-            }
453
-        }
454
-
455
-        return $this->_unlink($this->_file);
456
-    }
457
-
458
-    /**
459
-     * Clean the cache
460
-     *
461
-     * if no group is specified all cache files will be destroyed
462
-     * else only cache files of the specified group will be destroyed
463
-     *
464
-     * @param bool|string $group              name of the cache group
465
-     * @param string      $mode               flush cache mode : 'old', 'ingroup', 'notingroup',
466
-     *                                        'callback_myFunction'
467
-     * @return bool true if no problem
468
-     * @access public
469
-     */
470
-    public function clean($group = false, $mode = 'ingroup')
471
-    {
472
-        return $this->_cleanDir($this->_cacheDir, $group, $mode);
473
-    }
474
-
475
-    /**
476
-     * Set to debug mode
477
-     *
478
-     * When an error is found, the script will stop and the message will be displayed
479
-     * (in debug mode only).
480
-     *
481
-     * @access public
482
-     */
483
-    public function setToDebug()
484
-    {
485
-        $this->setOption('pearErrorMode', REFERENCES_CACHE_LITE_ERROR_DIE);
486
-    }
487
-
488
-    /**
489
-     * Set a new life time
490
-     *
491
-     * @param int $newLifeTime new life time (in seconds)
492
-     * @access public
493
-     */
494
-    public function setLifeTime($newLifeTime)
495
-    {
496
-        $this->_lifeTime = $newLifeTime;
497
-        $this->_setRefreshTime();
498
-    }
499
-
500
-    /**
501
-     * Save the state of the caching memory array into a cache file cache
502
-     *
503
-     * @param string $id    cache id
504
-     * @param string $group name of the cache group
505
-     * @access public
506
-     */
507
-    public function saveMemoryCachingState($id, $group = 'default')
508
-    {
509
-        if ($this->_caching) {
510
-            $array = array(
511
-                'counter' => $this->_memoryCachingCounter,
512
-                'array'   => $this->_memoryCachingArray
513
-            );
514
-            $data  = serialize($array);
515
-            $this->save($data, $id, $group);
516
-        }
517
-    }
518
-
519
-    /**
520
-     * Load the state of the caching memory array from a given cache file cache
521
-     *
522
-     * @param string  $id                     cache id
523
-     * @param string  $group                  name of the cache group
524
-     * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
525
-     * @access public
526
-     */
527
-    public function getMemoryCachingState($id, $group = 'default', $doNotTestCacheValidity = false)
528
-    {
529
-        if ($this->_caching) {
530
-            if ($data = $this->get($id, $group, $doNotTestCacheValidity)) {
531
-                $array                       = unserialize($data);
532
-                $this->_memoryCachingCounter = $array['counter'];
533
-                $this->_memoryCachingArray   = $array['array'];
534
-            }
535
-        }
536
-    }
537
-
538
-    /**
539
-     * Return the cache last modification time
540
-     *
541
-     * BE CAREFUL : THIS METHOD IS FOR HACKING ONLY !
542
-     *
543
-     * @return int last modification time
544
-     */
545
-    public function lastModified()
546
-    {
547
-        return @filemtime($this->_file);
548
-    }
549
-
550
-    /**
551
-     * Trigger a PEAR error
552
-     *
553
-     * To improve performances, the PEAR.php file is included dynamically.
554
-     * The file is so included only when an error is triggered. So, in most
555
-     * cases, the file isn't included and perfs are much better.
556
-     *
557
-     * @param string $msg  error message
558
-     * @param int    $code error code
559
-     * @access public
560
-     * @return object
561
-     */
562
-    public function raiseError($msg, $code)
563
-    {
564
-        include_once('PEAR.php');
565
-
566
-        return references_PEAR::raiseError($msg, $code, $this->_pearErrorMode);
567
-    }
568
-
569
-    /**
570
-     * Extend the life of a valid cache file
571
-     *
572
-     * see http://pear.php.net/bugs/bug.php?id=6681
573
-     *
574
-     * @access public
575
-     */
576
-    public function extendLife()
577
-    {
578
-        @touch($this->_file);
579
-    }
580
-
581
-    // --- Private methods ---
582
-
583
-    /**
584
-     * Compute & set the refresh time
585
-     *
586
-     * @access private
587
-     */
588
-    public function _setRefreshTime()
589
-    {
590
-        if (is_null($this->_lifeTime)) {
591
-            $this->_refreshTime = null;
592
-        } else {
593
-            $this->_refreshTime = time() - $this->_lifeTime;
594
-        }
595
-    }
596
-
597
-    /**
598
-     * Remove a file
599
-     *
600
-     * @param string $file complete file path and name
601
-     * @return boolean true if no problem
602
-     * @access private
603
-     */
604
-    public function _unlink($file)
605
-    {
606
-        if (!@unlink($file)) {
607
-            return $this->raiseError('Cache_Lite : Unable to remove cache !', -3);
608
-        }
609
-
610
-        return true;
611
-    }
612
-
613
-    /**
614
-     * Recursive function for cleaning cache file in the given directory
615
-     *
616
-     * @param string      $dir   directory complete path (with a trailing slash)
617
-     * @param bool|string $group name of the cache group
618
-     * @param string      $mode  flush cache mode : 'old', 'ingroup', 'notingroup',
619
-     *                           'callback_myFunction'
620
-     * @return bool true if no problem
621
-     * @access private
622
-     */
623
-    public function _cleanDir($dir, $group = false, $mode = 'ingroup')
624
-    {
625
-        if ($this->_fileNameProtection) {
626
-            $motif = $group ? 'cache_' . md5($group) . '_' : 'cache_';
627
-        } else {
628
-            $motif = $group ? 'cache_' . $group . '_' : 'cache_';
629
-        }
630
-        if ($this->_memoryCaching) {
631
-            foreach ($this->_memoryCachingArray as $key => $v) {
632
-                if (strpos($key, $motif) !== false) {
633
-                    unset($this->_memoryCachingArray[$key]);
634
-                    --$this->_memoryCachingCounter;
635
-                }
636
-            }
637
-            if ($this->_onlyMemoryCaching) {
638
-                return true;
639
-            }
640
-        }
641
-        if (!($dh = opendir($dir))) {
642
-            return $this->raiseError('Cache_Lite : Unable to open cache directory !', -4);
643
-        }
644
-        $result = true;
645
-        while ($file = readdir($dh)) {
646
-            if (($file !== '.') && ($file !== '..')) {
647
-                if (substr($file, 0, 6) === 'cache_') {
648
-                    $file2 = $dir . $file;
649
-                    if (is_file($file2)) {
650
-                        switch (substr($mode, 0, 9)) {
651
-                            case 'old':
652
-                                // files older than lifeTime get deleted from cache
653
-                                if (!is_null($this->_lifeTime)) {
654
-                                    if ((time() - @filemtime($file2)) > $this->_lifeTime) {
655
-                                        $result = ($result and $this->_unlink($file2));
656
-                                    }
657
-                                }
658
-                                break;
659
-                            case 'notingrou':
660
-                                if (strpos($file2, $motif) === false) {
661
-                                    $result = ($result and $this->_unlink($file2));
662
-                                }
663
-                                break;
664
-                            case 'callback_':
665
-                                $func = substr($mode, 9, strlen($mode) - 9);
666
-                                if ($func($file2, $group)) {
667
-                                    $result = ($result and $this->_unlink($file2));
668
-                                }
669
-                                break;
670
-                            case 'ingroup':
671
-                            default:
672
-                                if (strpos($file2, $motif) !== false) {
673
-                                    $result = ($result and $this->_unlink($file2));
674
-                                }
675
-                                break;
676
-                        }
677
-                    }
678
-                    if (is_dir($file2) and ($this->_hashedDirectoryLevel > 0)) {
679
-                        $result = ($result and $this->_cleanDir($file2 . '/', $group, $mode));
680
-                    }
681
-                }
682
-            }
683
-        }
684
-
685
-        return $result;
686
-    }
687
-
688
-    /**
689
-     * Add some date in the memory caching array
690
-     *
691
-     * @param string $data data to cache
692
-     * @access private
693
-     */
694
-    public function _memoryCacheAdd($data)
695
-    {
696
-        $this->_memoryCachingArray[$this->_file] = $data;
697
-        if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) {
698
-            list($key,) = each($this->_memoryCachingArray);
699
-            unset($this->_memoryCachingArray[$key]);
700
-        } else {
701
-            ++$this->_memoryCachingCounter;
702
-        }
703
-    }
704
-
705
-    /**
706
-     * Make a file name (with path)
707
-     *
708
-     * @param string $id    cache id
709
-     * @param string $group name of the group
710
-     * @access private
711
-     */
712
-    public function _setFileName($id, $group)
713
-    {
714
-        if ($this->_fileNameProtection) {
715
-            $suffix = 'cache_' . md5($group) . '_' . md5($id);
716
-        } else {
717
-            $suffix = 'cache_' . $group . '_' . $id;
718
-        }
719
-        $root = $this->_cacheDir;
720
-        if ($this->_hashedDirectoryLevel > 0) {
721
-            $hash = md5($suffix);
722
-            for ($i = 0; $i < $this->_hashedDirectoryLevel; ++$i) {
723
-                $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
724
-            }
725
-        }
726
-        $this->_fileName = $suffix;
727
-        $this->_file     = $root . $suffix;
728
-    }
729
-
730
-    /**
731
-     * Read the cache file and return the content
732
-     *
733
-     * @return string content of the cache file (else : false or a PEAR_Error object)
734
-     * @access private
735
-     */
736
-    public function _read()
737
-    {
738
-        $fp = @fopen($this->_file, 'rb');
739
-        if ($this->_fileLocking) {
740
-            @flock($fp, LOCK_SH);
741
-        }
742
-        if ($fp) {
743
-            clearstatcache();
744
-            $length = @filesize($this->_file);
745
-            //            $mqr = get_magic_quotes_runtime();
746
-            //            @set_magic_quotes_runtime(0);
747
-            if ($this->_readControl) {
748
-                $hashControl = @fread($fp, 32);
749
-                $length      = $length - 32;
750
-            }
751
-            if ($length) {
752
-                $data = @fread($fp, $length);
753
-            } else {
754
-                $data = '';
755
-            }
756
-            //            @set_magic_quotes_runtime($mqr);
757
-            if ($this->_fileLocking) {
758
-                @flock($fp, LOCK_UN);
759
-            }
760
-            @fclose($fp);
761
-            if ($this->_readControl) {
762
-                $hashData = $this->_hash($data, $this->_readControlType);
763
-                if ($hashData != $hashControl) {
764
-                    if (!is_null($this->_lifeTime)) {
765
-                        @touch($this->_file, time() - 2 * abs($this->_lifeTime));
766
-                    } else {
767
-                        @unlink($this->_file);
768
-                    }
769
-
770
-                    return false;
771
-                }
772
-            }
773
-
774
-            return $data;
775
-        }
776
-
777
-        return $this->raiseError('Cache_Lite : Unable to read cache !', -2);
778
-    }
779
-
780
-    /**
781
-     * Write the given data in the cache file
782
-     *
783
-     * @param string $data data to put in cache
784
-     * @return boolean true if ok (a PEAR_Error object else)
785
-     * @access private
786
-     */
787
-    public function _write($data)
788
-    {
789
-        if ($this->_hashedDirectoryLevel > 0) {
790
-            $hash = md5($this->_fileName);
791
-            $root = $this->_cacheDir;
792
-            for ($i = 0; $i < $this->_hashedDirectoryLevel; ++$i) {
793
-                $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
794
-                if (!(@is_dir($root))) {
795
-                    @mkdir($root, $this->_hashedDirectoryUmask);
796
-                }
797
-            }
798
-        }
799
-        $fp = @fopen($this->_file, 'wb');
800
-        if ($fp) {
801
-            if ($this->_fileLocking) {
802
-                @flock($fp, LOCK_EX);
803
-            }
804
-            if ($this->_readControl) {
805
-                @fwrite($fp, $this->_hash($data, $this->_readControlType), 32);
806
-            }
807
-            //            $mqr = get_magic_quotes_runtime();
808
-            //            @set_magic_quotes_runtime(0);
809
-            @fwrite($fp, $data);
810
-            //            @set_magic_quotes_runtime($mqr);
811
-            if ($this->_fileLocking) {
812
-                @flock($fp, LOCK_UN);
813
-            }
814
-            @fclose($fp);
815
-
816
-            return true;
817
-        }
818
-
819
-        return $this->raiseError('Cache_Lite : Unable to write cache file : ' . $this->_file, -1);
820
-    }
821
-
822
-    /**
823
-     * Write the given data in the cache file and control it just after to avoir corrupted cache entries
824
-     *
825
-     * @param string $data data to put in cache
826
-     * @return boolean true if the test is ok (else : false or a PEAR_Error object)
827
-     * @access private
828
-     */
829
-    public function _writeAndControl($data)
830
-    {
831
-        $result = $this->_write($data);
832
-        if (is_object($result)) {
833
-            return $result; # We return the PEAR_Error object
834
-        }
835
-        $dataRead = $this->_read();
836
-        if (is_object($dataRead)) {
837
-            return $dataRead; # We return the PEAR_Error object
838
-        }
839
-        if (is_bool($dataRead) && (!$dataRead)) {
840
-            return false;
841
-        }
842
-
843
-        return ($dataRead == $data);
844
-    }
845
-
846
-    /**
847
-     * Make a control key with the string containing datas
848
-     *
849
-     * @param string $data        data
850
-     * @param string $controlType type of control 'md5', 'crc32' or 'strlen'
851
-     * @return string control key
852
-     * @access private
853
-     */
854
-    public function _hash($data, $controlType)
855
-    {
856
-        switch ($controlType) {
857
-            case 'md5':
858
-                return md5($data);
859
-            case 'crc32':
860
-                return sprintf('% 32d', crc32($data));
861
-            case 'strlen':
862
-                return sprintf('% 32d', strlen($data));
863
-            default:
864
-                return $this->raiseError('Unknown controlType ! (available values are only \'md5\', \'crc32\', \'strlen\')', -5);
865
-        }
866
-    }
31
+	// --- Private properties ---
32
+
33
+	/**
34
+	 * Directory where to put the cache files
35
+	 * (make sure to add a trailing slash)
36
+	 *
37
+	 * @var string $_cacheDir
38
+	 */
39
+	public $_cacheDir = '/tmp/';
40
+
41
+	/**
42
+	 * Enable / disable caching
43
+	 *
44
+	 * (can be very usefull for the debug of cached scripts)
45
+	 *
46
+	 * @var boolean $_caching
47
+	 */
48
+	public $_caching = true;
49
+
50
+	/**
51
+	 * Cache lifetime (in seconds)
52
+	 *
53
+	 * If null, the cache is valid forever.
54
+	 *
55
+	 * @var int $_lifeTime
56
+	 */
57
+	public $_lifeTime = 3600;
58
+
59
+	/**
60
+	 * Enable / disable fileLocking
61
+	 *
62
+	 * (can avoid cache corruption under bad circumstances)
63
+	 *
64
+	 * @var boolean $_fileLocking
65
+	 */
66
+	public $_fileLocking = true;
67
+
68
+	/**
69
+	 * Timestamp of the last valid cache
70
+	 *
71
+	 * @var int $_refreshTime
72
+	 */
73
+	public $_refreshTime;
74
+
75
+	/**
76
+	 * File name (with path)
77
+	 *
78
+	 * @var string $_file
79
+	 */
80
+	public $_file;
81
+
82
+	/**
83
+	 * File name (without path)
84
+	 *
85
+	 * @var string $_fileName
86
+	 */
87
+	public $_fileName;
88
+
89
+	/**
90
+	 * Enable / disable write control (the cache is read just after writing to detect corrupt entries)
91
+	 *
92
+	 * Enable write control will lightly slow the cache writing but not the cache reading
93
+	 * Write control can detect some corrupt cache files but maybe it's not a perfect control
94
+	 *
95
+	 * @var boolean $_writeControl
96
+	 */
97
+	public $_writeControl = true;
98
+
99
+	/**
100
+	 * Enable / disable read control
101
+	 *
102
+	 * If enabled, a control key is embeded in cache file and this key is compared with the one
103
+	 * calculated after the reading.
104
+	 *
105
+	 * @var boolean $_writeControl
106
+	 */
107
+	public $_readControl = true;
108
+
109
+	/**
110
+	 * Type of read control (only if read control is enabled)
111
+	 *
112
+	 * Available values are :
113
+	 * 'md5' for a md5 hash control (best but slowest)
114
+	 * 'crc32' for a crc32 hash control (lightly less safe but faster, better choice)
115
+	 * 'strlen' for a length only test (fastest)
116
+	 *
117
+	 * @var boolean $_readControlType
118
+	 */
119
+	public $_readControlType = 'crc32';
120
+
121
+	/**
122
+	 * Pear error mode (when raiseError is called)
123
+	 *
124
+	 * (see PEAR doc)
125
+	 *
126
+	 * @see setToDebug()
127
+	 * @var int $_pearErrorMode
128
+	 */
129
+	public $_pearErrorMode = REFERENCES_CACHE_LITE_ERROR_RETURN;
130
+
131
+	/**
132
+	 * Current cache id
133
+	 *
134
+	 * @var string $_id
135
+	 */
136
+	public $_id;
137
+
138
+	/**
139
+	 * Current cache group
140
+	 *
141
+	 * @var string $_group
142
+	 */
143
+	public $_group;
144
+
145
+	/**
146
+	 * Enable / Disable "Memory Caching"
147
+	 *
148
+	 * NB : There is no lifetime for memory caching !
149
+	 *
150
+	 * @var boolean $_memoryCaching
151
+	 */
152
+	public $_memoryCaching = false;
153
+
154
+	/**
155
+	 * Enable / Disable "Only Memory Caching"
156
+	 * (be carefull, memory caching is "beta quality")
157
+	 *
158
+	 * @var boolean $_onlyMemoryCaching
159
+	 */
160
+	public $_onlyMemoryCaching = false;
161
+
162
+	/**
163
+	 * Memory caching array
164
+	 *
165
+	 * @var array $_memoryCachingArray
166
+	 */
167
+	public $_memoryCachingArray = array();
168
+
169
+	/**
170
+	 * Memory caching counter
171
+	 *
172
+	 * @var int $memoryCachingCounter
173
+	 */
174
+	public $_memoryCachingCounter = 0;
175
+
176
+	/**
177
+	 * Memory caching limit
178
+	 *
179
+	 * @var int $memoryCachingLimit
180
+	 */
181
+	public $_memoryCachingLimit = 1000;
182
+
183
+	/**
184
+	 * File Name protection
185
+	 *
186
+	 * if set to true, you can use any cache id or group name
187
+	 * if set to false, it can be faster but cache ids and group names
188
+	 * will be used directly in cache file names so be carefull with
189
+	 * special characters...
190
+	 *
191
+	 * @var boolean $fileNameProtection
192
+	 */
193
+	public $_fileNameProtection = true;
194
+
195
+	/**
196
+	 * Enable / disable automatic serialization
197
+	 *
198
+	 * it can be used to save directly datas which aren't strings
199
+	 * (but it's slower)
200
+	 *
201
+	 * @var boolean $_serialize
202
+	 */
203
+	public $_automaticSerialization = false;
204
+
205
+	/**
206
+	 * Disable / Tune the automatic cleaning process
207
+	 *
208
+	 * The automatic cleaning process destroy too old (for the given life time)
209
+	 * cache files when a new cache file is written.
210
+	 * 0               => no automatic cache cleaning
211
+	 * 1               => systematic cache cleaning
212
+	 * x (integer) > 1 => automatic cleaning randomly 1 times on x cache write
213
+	 *
214
+	 * @var int $_automaticCleaning
215
+	 */
216
+	public $_automaticCleaningFactor = 0;
217
+
218
+	/**
219
+	 * Nested directory level
220
+	 *
221
+	 * Set the hashed directory structure level. 0 means "no hashed directory
222
+	 * structure", 1 means "one level of directory", 2 means "two levels"...
223
+	 * This option can speed up Cache_Lite only when you have many thousands of
224
+	 * cache file. Only specific benchs can help you to choose the perfect value
225
+	 * for you. Maybe, 1 or 2 is a good start.
226
+	 *
227
+	 * @var int $_hashedDirectoryLevel
228
+	 */
229
+	public $_hashedDirectoryLevel = 0;
230
+
231
+	/**
232
+	 * Umask for hashed directory structure
233
+	 *
234
+	 * @var int $_hashedDirectoryUmask
235
+	 */
236
+	public $_hashedDirectoryUmask = 0700;
237
+
238
+	/**
239
+	 * API break for error handling in REFERENCES_CACHE_LITE_ERROR_RETURN mode
240
+	 *
241
+	 * In REFERENCES_CACHE_LITE_ERROR_RETURN mode, error handling was not good because
242
+	 * for example save() method always returned a boolean (a PEAR_Error object
243
+	 * would be better in REFERENCES_CACHE_LITE_ERROR_RETURN mode). To correct this without
244
+	 * breaking the API, this option (false by default) can change this handling.
245
+	 *
246
+	 * @var boolean
247
+	 */
248
+	public $_errorHandlingAPIBreak = false;
249
+
250
+	// --- Public methods ---
251
+
252
+	/**
253
+	 * Constructor
254
+	 *
255
+	 * $options is an assoc. Available options are :
256
+	 * $options = array(
257
+	 *     'cacheDir' => directory where to put the cache files (string) ,
258
+	 *     'caching' => enable / disable caching (boolean) ,
259
+	 *     'lifeTime' => cache lifetime in seconds (int) ,
260
+	 *     'fileLocking' => enable / disable fileLocking (boolean) ,
261
+	 *     'writeControl' => enable / disable write control (boolean) ,
262
+	 *     'readControl' => enable / disable read control (boolean) ,
263
+	 *     'readControlType' => type of read control 'crc32', 'md5', 'strlen' (string) ,
264
+	 *     'pearErrorMode' => pear error mode (when raiseError is called) (cf PEAR doc) (int) ,
265
+	 *     'memoryCaching' => enable / disable memory caching (boolean) ,
266
+	 *     'onlyMemoryCaching' => enable / disable only memory caching (boolean) ,
267
+	 *     'memoryCachingLimit' => max nbr of records to store into memory caching (int) ,
268
+	 *     'fileNameProtection' => enable / disable automatic file name protection (boolean) ,
269
+	 *     'automaticSerialization' => enable / disable automatic serialization (boolean) ,
270
+	 *     'automaticCleaningFactor' => distable / tune automatic cleaning process (int) ,
271
+	 *     'hashedDirectoryLevel' => level of the hashed directory system (int) ,
272
+	 *     'hashedDirectoryUmask' => umask for hashed directory structure (int) ,
273
+	 *     'errorHandlingAPIBreak' => API break for better error handling ? (boolean)
274
+	 * );
275
+	 *
276
+	 * @param array $options options
277
+	 * @access public
278
+	 */
279
+	public function __construct($options = array(null))
280
+	{
281
+		foreach ($options as $key => $value) {
282
+			$this->setOption($key, $value);
283
+		}
284
+	}
285
+
286
+	/**
287
+	 * Generic way to set a Cache_Lite option
288
+	 *
289
+	 * see Cache_Lite constructor for available options
290
+	 *
291
+	 * @var string $name  name of the option
292
+	 * @var mixed  $value value of the option
293
+	 * @access public
294
+	 */
295
+	public function setOption($name, $value)
296
+	{
297
+		$availableOptions = array(
298
+			'errorHandlingAPIBreak',
299
+			'hashedDirectoryUmask',
300
+			'hashedDirectoryLevel',
301
+			'automaticCleaningFactor',
302
+			'automaticSerialization',
303
+			'fileNameProtection',
304
+			'memoryCaching',
305
+			'onlyMemoryCaching',
306
+			'memoryCachingLimit',
307
+			'cacheDir',
308
+			'caching',
309
+			'lifeTime',
310
+			'fileLocking',
311
+			'writeControl',
312
+			'readControl',
313
+			'readControlType',
314
+			'pearErrorMode'
315
+		);
316
+		if (in_array($name, $availableOptions)) {
317
+			$property        = '_' . $name;
318
+			$this->$property = $value;
319
+		}
320
+	}
321
+
322
+	/**
323
+	 * Test if a cache is available and (if yes) return it
324
+	 *
325
+	 * @param string  $id                     cache id
326
+	 * @param string  $group                  name of the cache group
327
+	 * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
328
+	 * @return string data of the cache (else : false)
329
+	 * @access public
330
+	 */
331
+	public function get($id, $group = 'default', $doNotTestCacheValidity = false)
332
+	{
333
+		$this->_id    = $id;
334
+		$this->_group = $group;
335
+		$data         = false;
336
+		if ($this->_caching) {
337
+			$this->_setRefreshTime();
338
+			$this->_setFileName($id, $group);
339
+			clearstatcache();
340
+			if ($this->_memoryCaching) {
341
+				if (isset($this->_memoryCachingArray[$this->_file])) {
342
+					if ($this->_automaticSerialization) {
343
+						return unserialize($this->_memoryCachingArray[$this->_file]);
344
+					}
345
+
346
+					return $this->_memoryCachingArray[$this->_file];
347
+				}
348
+				if ($this->_onlyMemoryCaching) {
349
+					return false;
350
+				}
351
+			}
352
+			if ($doNotTestCacheValidity || is_null($this->_refreshTime)) {
353
+				if (file_exists($this->_file)) {
354
+					$data = $this->_read();
355
+				}
356
+			} else {
357
+				if (file_exists($this->_file) && (@filemtime($this->_file) > $this->_refreshTime)) {
358
+					$data = $this->_read();
359
+				}
360
+			}
361
+			if ($data && $this->_memoryCaching) {
362
+				$this->_memoryCacheAdd($data);
363
+			}
364
+			if ($this->_automaticSerialization && is_string($data)) {
365
+				$data = unserialize($data);
366
+			}
367
+
368
+			return $data;
369
+		}
370
+
371
+		return false;
372
+	}
373
+
374
+	/**
375
+	 * Save some data in a cache file
376
+	 *
377
+	 * @param string $data  data to put in cache (can be another type than strings if automaticSerialization is on)
378
+	 * @param string $id    cache id
379
+	 * @param string $group name of the cache group
380
+	 * @return boolean true if no problem (else : false or a PEAR_Error object)
381
+	 * @access public
382
+	 */
383
+	public function save($data, $id = null, $group = 'default')
384
+	{
385
+		if ($this->_caching) {
386
+			if ($this->_automaticSerialization) {
387
+				$data = serialize($data);
388
+			}
389
+			if (isset($id)) {
390
+				$this->_setFileName($id, $group);
391
+			}
392
+			if ($this->_memoryCaching) {
393
+				$this->_memoryCacheAdd($data);
394
+				if ($this->_onlyMemoryCaching) {
395
+					return true;
396
+				}
397
+			}
398
+			if ($this->_automaticCleaningFactor > 0 && ($this->_automaticCleaningFactor == 1 || mt_rand(1, $this->_automaticCleaningFactor) == 1)) {
399
+				$this->clean(false, 'old');
400
+			}
401
+			if ($this->_writeControl) {
402
+				$res = $this->_writeAndControl($data);
403
+				if (is_bool($res)) {
404
+					if ($res) {
405
+						return true;
406
+					}
407
+					// if $res if false, we need to invalidate the cache
408
+					@touch($this->_file, time() - 2 * abs($this->_lifeTime));
409
+
410
+					return false;
411
+				}
412
+			} else {
413
+				$res = $this->_write($data);
414
+			}
415
+			if (is_object($res)) {
416
+				// $res is a PEAR_Error object
417
+				if (!$this->_errorHandlingAPIBreak) {
418
+					return false; // we return false (old API)
419
+				}
420
+			}
421
+
422
+			return $res;
423
+		}
424
+
425
+		return false;
426
+	}
427
+
428
+	/**
429
+	 * Remove a cache file
430
+	 *
431
+	 * @param string  $id                cache id
432
+	 * @param string  $group             name of the cache group
433
+	 * @param boolean $checkbeforeunlink check if file exists before removing it
434
+	 * @return boolean true if no problem
435
+	 * @access public
436
+	 */
437
+	public function remove($id, $group = 'default', $checkbeforeunlink = false)
438
+	{
439
+		$this->_setFileName($id, $group);
440
+		if ($this->_memoryCaching) {
441
+			if (isset($this->_memoryCachingArray[$this->_file])) {
442
+				unset($this->_memoryCachingArray[$this->_file]);
443
+				--$this->_memoryCachingCounter;
444
+			}
445
+			if ($this->_onlyMemoryCaching) {
446
+				return true;
447
+			}
448
+		}
449
+		if ($checkbeforeunlink) {
450
+			if (!file_exists($this->_file)) {
451
+				return true;
452
+			}
453
+		}
454
+
455
+		return $this->_unlink($this->_file);
456
+	}
457
+
458
+	/**
459
+	 * Clean the cache
460
+	 *
461
+	 * if no group is specified all cache files will be destroyed
462
+	 * else only cache files of the specified group will be destroyed
463
+	 *
464
+	 * @param bool|string $group              name of the cache group
465
+	 * @param string      $mode               flush cache mode : 'old', 'ingroup', 'notingroup',
466
+	 *                                        'callback_myFunction'
467
+	 * @return bool true if no problem
468
+	 * @access public
469
+	 */
470
+	public function clean($group = false, $mode = 'ingroup')
471
+	{
472
+		return $this->_cleanDir($this->_cacheDir, $group, $mode);
473
+	}
474
+
475
+	/**
476
+	 * Set to debug mode
477
+	 *
478
+	 * When an error is found, the script will stop and the message will be displayed
479
+	 * (in debug mode only).
480
+	 *
481
+	 * @access public
482
+	 */
483
+	public function setToDebug()
484
+	{
485
+		$this->setOption('pearErrorMode', REFERENCES_CACHE_LITE_ERROR_DIE);
486
+	}
487
+
488
+	/**
489
+	 * Set a new life time
490
+	 *
491
+	 * @param int $newLifeTime new life time (in seconds)
492
+	 * @access public
493
+	 */
494
+	public function setLifeTime($newLifeTime)
495
+	{
496
+		$this->_lifeTime = $newLifeTime;
497
+		$this->_setRefreshTime();
498
+	}
499
+
500
+	/**
501
+	 * Save the state of the caching memory array into a cache file cache
502
+	 *
503
+	 * @param string $id    cache id
504
+	 * @param string $group name of the cache group
505
+	 * @access public
506
+	 */
507
+	public function saveMemoryCachingState($id, $group = 'default')
508
+	{
509
+		if ($this->_caching) {
510
+			$array = array(
511
+				'counter' => $this->_memoryCachingCounter,
512
+				'array'   => $this->_memoryCachingArray
513
+			);
514
+			$data  = serialize($array);
515
+			$this->save($data, $id, $group);
516
+		}
517
+	}
518
+
519
+	/**
520
+	 * Load the state of the caching memory array from a given cache file cache
521
+	 *
522
+	 * @param string  $id                     cache id
523
+	 * @param string  $group                  name of the cache group
524
+	 * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
525
+	 * @access public
526
+	 */
527
+	public function getMemoryCachingState($id, $group = 'default', $doNotTestCacheValidity = false)
528
+	{
529
+		if ($this->_caching) {
530
+			if ($data = $this->get($id, $group, $doNotTestCacheValidity)) {
531
+				$array                       = unserialize($data);
532
+				$this->_memoryCachingCounter = $array['counter'];
533
+				$this->_memoryCachingArray   = $array['array'];
534
+			}
535
+		}
536
+	}
537
+
538
+	/**
539
+	 * Return the cache last modification time
540
+	 *
541
+	 * BE CAREFUL : THIS METHOD IS FOR HACKING ONLY !
542
+	 *
543
+	 * @return int last modification time
544
+	 */
545
+	public function lastModified()
546
+	{
547
+		return @filemtime($this->_file);
548
+	}
549
+
550
+	/**
551
+	 * Trigger a PEAR error
552
+	 *
553
+	 * To improve performances, the PEAR.php file is included dynamically.
554
+	 * The file is so included only when an error is triggered. So, in most
555
+	 * cases, the file isn't included and perfs are much better.
556
+	 *
557
+	 * @param string $msg  error message
558
+	 * @param int    $code error code
559
+	 * @access public
560
+	 * @return object
561
+	 */
562
+	public function raiseError($msg, $code)
563
+	{
564
+		include_once('PEAR.php');
565
+
566
+		return references_PEAR::raiseError($msg, $code, $this->_pearErrorMode);
567
+	}
568
+
569
+	/**
570
+	 * Extend the life of a valid cache file
571
+	 *
572
+	 * see http://pear.php.net/bugs/bug.php?id=6681
573
+	 *
574
+	 * @access public
575
+	 */
576
+	public function extendLife()
577
+	{
578
+		@touch($this->_file);
579
+	}
580
+
581
+	// --- Private methods ---
582
+
583
+	/**
584
+	 * Compute & set the refresh time
585
+	 *
586
+	 * @access private
587
+	 */
588
+	public function _setRefreshTime()
589
+	{
590
+		if (is_null($this->_lifeTime)) {
591
+			$this->_refreshTime = null;
592
+		} else {
593
+			$this->_refreshTime = time() - $this->_lifeTime;
594
+		}
595
+	}
596
+
597
+	/**
598
+	 * Remove a file
599
+	 *
600
+	 * @param string $file complete file path and name
601
+	 * @return boolean true if no problem
602
+	 * @access private
603
+	 */
604
+	public function _unlink($file)
605
+	{
606
+		if (!@unlink($file)) {
607
+			return $this->raiseError('Cache_Lite : Unable to remove cache !', -3);
608
+		}
609
+
610
+		return true;
611
+	}
612
+
613
+	/**
614
+	 * Recursive function for cleaning cache file in the given directory
615
+	 *
616
+	 * @param string      $dir   directory complete path (with a trailing slash)
617
+	 * @param bool|string $group name of the cache group
618
+	 * @param string      $mode  flush cache mode : 'old', 'ingroup', 'notingroup',
619
+	 *                           'callback_myFunction'
620
+	 * @return bool true if no problem
621
+	 * @access private
622
+	 */
623
+	public function _cleanDir($dir, $group = false, $mode = 'ingroup')
624
+	{
625
+		if ($this->_fileNameProtection) {
626
+			$motif = $group ? 'cache_' . md5($group) . '_' : 'cache_';
627
+		} else {
628
+			$motif = $group ? 'cache_' . $group . '_' : 'cache_';
629
+		}
630
+		if ($this->_memoryCaching) {
631
+			foreach ($this->_memoryCachingArray as $key => $v) {
632
+				if (strpos($key, $motif) !== false) {
633
+					unset($this->_memoryCachingArray[$key]);
634
+					--$this->_memoryCachingCounter;
635
+				}
636
+			}
637
+			if ($this->_onlyMemoryCaching) {
638
+				return true;
639
+			}
640
+		}
641
+		if (!($dh = opendir($dir))) {
642
+			return $this->raiseError('Cache_Lite : Unable to open cache directory !', -4);
643
+		}
644
+		$result = true;
645
+		while ($file = readdir($dh)) {
646
+			if (($file !== '.') && ($file !== '..')) {
647
+				if (substr($file, 0, 6) === 'cache_') {
648
+					$file2 = $dir . $file;
649
+					if (is_file($file2)) {
650
+						switch (substr($mode, 0, 9)) {
651
+							case 'old':
652
+								// files older than lifeTime get deleted from cache
653
+								if (!is_null($this->_lifeTime)) {
654
+									if ((time() - @filemtime($file2)) > $this->_lifeTime) {
655
+										$result = ($result and $this->_unlink($file2));
656
+									}
657
+								}
658
+								break;
659
+							case 'notingrou':
660
+								if (strpos($file2, $motif) === false) {
661
+									$result = ($result and $this->_unlink($file2));
662
+								}
663
+								break;
664
+							case 'callback_':
665
+								$func = substr($mode, 9, strlen($mode) - 9);
666
+								if ($func($file2, $group)) {
667
+									$result = ($result and $this->_unlink($file2));
668
+								}
669
+								break;
670
+							case 'ingroup':
671
+							default:
672
+								if (strpos($file2, $motif) !== false) {
673
+									$result = ($result and $this->_unlink($file2));
674
+								}
675
+								break;
676
+						}
677
+					}
678
+					if (is_dir($file2) and ($this->_hashedDirectoryLevel > 0)) {
679
+						$result = ($result and $this->_cleanDir($file2 . '/', $group, $mode));
680
+					}
681
+				}
682
+			}
683
+		}
684
+
685
+		return $result;
686
+	}
687
+
688
+	/**
689
+	 * Add some date in the memory caching array
690
+	 *
691
+	 * @param string $data data to cache
692
+	 * @access private
693
+	 */
694
+	public function _memoryCacheAdd($data)
695
+	{
696
+		$this->_memoryCachingArray[$this->_file] = $data;
697
+		if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) {
698
+			list($key,) = each($this->_memoryCachingArray);
699
+			unset($this->_memoryCachingArray[$key]);
700
+		} else {
701
+			++$this->_memoryCachingCounter;
702
+		}
703
+	}
704
+
705
+	/**
706
+	 * Make a file name (with path)
707
+	 *
708
+	 * @param string $id    cache id
709
+	 * @param string $group name of the group
710
+	 * @access private
711
+	 */
712
+	public function _setFileName($id, $group)
713
+	{
714
+		if ($this->_fileNameProtection) {
715
+			$suffix = 'cache_' . md5($group) . '_' . md5($id);
716
+		} else {
717
+			$suffix = 'cache_' . $group . '_' . $id;
718
+		}
719
+		$root = $this->_cacheDir;
720
+		if ($this->_hashedDirectoryLevel > 0) {
721
+			$hash = md5($suffix);
722
+			for ($i = 0; $i < $this->_hashedDirectoryLevel; ++$i) {
723
+				$root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
724
+			}
725
+		}
726
+		$this->_fileName = $suffix;
727
+		$this->_file     = $root . $suffix;
728
+	}
729
+
730
+	/**
731
+	 * Read the cache file and return the content
732
+	 *
733
+	 * @return string content of the cache file (else : false or a PEAR_Error object)
734
+	 * @access private
735
+	 */
736
+	public function _read()
737
+	{
738
+		$fp = @fopen($this->_file, 'rb');
739
+		if ($this->_fileLocking) {
740
+			@flock($fp, LOCK_SH);
741
+		}
742
+		if ($fp) {
743
+			clearstatcache();
744
+			$length = @filesize($this->_file);
745
+			//            $mqr = get_magic_quotes_runtime();
746
+			//            @set_magic_quotes_runtime(0);
747
+			if ($this->_readControl) {
748
+				$hashControl = @fread($fp, 32);
749
+				$length      = $length - 32;
750
+			}
751
+			if ($length) {
752
+				$data = @fread($fp, $length);
753
+			} else {
754
+				$data = '';
755
+			}
756
+			//            @set_magic_quotes_runtime($mqr);
757
+			if ($this->_fileLocking) {
758
+				@flock($fp, LOCK_UN);
759
+			}
760
+			@fclose($fp);
761
+			if ($this->_readControl) {
762
+				$hashData = $this->_hash($data, $this->_readControlType);
763
+				if ($hashData != $hashControl) {
764
+					if (!is_null($this->_lifeTime)) {
765
+						@touch($this->_file, time() - 2 * abs($this->_lifeTime));
766
+					} else {
767
+						@unlink($this->_file);
768
+					}
769
+
770
+					return false;
771
+				}
772
+			}
773
+
774
+			return $data;
775
+		}
776
+
777
+		return $this->raiseError('Cache_Lite : Unable to read cache !', -2);
778
+	}
779
+
780
+	/**
781
+	 * Write the given data in the cache file
782
+	 *
783
+	 * @param string $data data to put in cache
784
+	 * @return boolean true if ok (a PEAR_Error object else)
785
+	 * @access private
786
+	 */
787
+	public function _write($data)
788
+	{
789
+		if ($this->_hashedDirectoryLevel > 0) {
790
+			$hash = md5($this->_fileName);
791
+			$root = $this->_cacheDir;
792
+			for ($i = 0; $i < $this->_hashedDirectoryLevel; ++$i) {
793
+				$root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
794
+				if (!(@is_dir($root))) {
795
+					@mkdir($root, $this->_hashedDirectoryUmask);
796
+				}
797
+			}
798
+		}
799
+		$fp = @fopen($this->_file, 'wb');
800
+		if ($fp) {
801
+			if ($this->_fileLocking) {
802
+				@flock($fp, LOCK_EX);
803
+			}
804
+			if ($this->_readControl) {
805
+				@fwrite($fp, $this->_hash($data, $this->_readControlType), 32);
806
+			}
807
+			//            $mqr = get_magic_quotes_runtime();
808
+			//            @set_magic_quotes_runtime(0);
809
+			@fwrite($fp, $data);
810
+			//            @set_magic_quotes_runtime($mqr);
811
+			if ($this->_fileLocking) {
812
+				@flock($fp, LOCK_UN);
813
+			}
814
+			@fclose($fp);
815
+
816
+			return true;
817
+		}
818
+
819
+		return $this->raiseError('Cache_Lite : Unable to write cache file : ' . $this->_file, -1);
820
+	}
821
+
822
+	/**
823
+	 * Write the given data in the cache file and control it just after to avoir corrupted cache entries
824
+	 *
825
+	 * @param string $data data to put in cache
826
+	 * @return boolean true if the test is ok (else : false or a PEAR_Error object)
827
+	 * @access private
828
+	 */
829
+	public function _writeAndControl($data)
830
+	{
831
+		$result = $this->_write($data);
832
+		if (is_object($result)) {
833
+			return $result; # We return the PEAR_Error object
834
+		}
835
+		$dataRead = $this->_read();
836
+		if (is_object($dataRead)) {
837
+			return $dataRead; # We return the PEAR_Error object
838
+		}
839
+		if (is_bool($dataRead) && (!$dataRead)) {
840
+			return false;
841
+		}
842
+
843
+		return ($dataRead == $data);
844
+	}
845
+
846
+	/**
847
+	 * Make a control key with the string containing datas
848
+	 *
849
+	 * @param string $data        data
850
+	 * @param string $controlType type of control 'md5', 'crc32' or 'strlen'
851
+	 * @return string control key
852
+	 * @access private
853
+	 */
854
+	public function _hash($data, $controlType)
855
+	{
856
+		switch ($controlType) {
857
+			case 'md5':
858
+				return md5($data);
859
+			case 'crc32':
860
+				return sprintf('% 32d', crc32($data));
861
+			case 'strlen':
862
+				return sprintf('% 32d', strlen($data));
863
+			default:
864
+				return $this->raiseError('Unknown controlType ! (available values are only \'md5\', \'crc32\', \'strlen\')', -5);
865
+		}
866
+	}
867 867
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             'pearErrorMode'
315 315
         );
316 316
         if (in_array($name, $availableOptions)) {
317
-            $property        = '_' . $name;
317
+            $property        = '_'.$name;
318 318
             $this->$property = $value;
319 319
         }
320 320
     }
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
                 'counter' => $this->_memoryCachingCounter,
512 512
                 'array'   => $this->_memoryCachingArray
513 513
             );
514
-            $data  = serialize($array);
514
+            $data = serialize($array);
515 515
             $this->save($data, $id, $group);
516 516
         }
517 517
     }
@@ -623,9 +623,9 @@  discard block
 block discarded – undo
623 623
     public function _cleanDir($dir, $group = false, $mode = 'ingroup')
624 624
     {
625 625
         if ($this->_fileNameProtection) {
626
-            $motif = $group ? 'cache_' . md5($group) . '_' : 'cache_';
626
+            $motif = $group ? 'cache_'.md5($group).'_' : 'cache_';
627 627
         } else {
628
-            $motif = $group ? 'cache_' . $group . '_' : 'cache_';
628
+            $motif = $group ? 'cache_'.$group.'_' : 'cache_';
629 629
         }
630 630
         if ($this->_memoryCaching) {
631 631
             foreach ($this->_memoryCachingArray as $key => $v) {
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
         while ($file = readdir($dh)) {
646 646
             if (($file !== '.') && ($file !== '..')) {
647 647
                 if (substr($file, 0, 6) === 'cache_') {
648
-                    $file2 = $dir . $file;
648
+                    $file2 = $dir.$file;
649 649
                     if (is_file($file2)) {
650 650
                         switch (substr($mode, 0, 9)) {
651 651
                             case 'old':
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
                         }
677 677
                     }
678 678
                     if (is_dir($file2) and ($this->_hashedDirectoryLevel > 0)) {
679
-                        $result = ($result and $this->_cleanDir($file2 . '/', $group, $mode));
679
+                        $result = ($result and $this->_cleanDir($file2.'/', $group, $mode));
680 680
                     }
681 681
                 }
682 682
             }
@@ -712,19 +712,19 @@  discard block
 block discarded – undo
712 712
     public function _setFileName($id, $group)
713 713
     {
714 714
         if ($this->_fileNameProtection) {
715
-            $suffix = 'cache_' . md5($group) . '_' . md5($id);
715
+            $suffix = 'cache_'.md5($group).'_'.md5($id);
716 716
         } else {
717
-            $suffix = 'cache_' . $group . '_' . $id;
717
+            $suffix = 'cache_'.$group.'_'.$id;
718 718
         }
719 719
         $root = $this->_cacheDir;
720 720
         if ($this->_hashedDirectoryLevel > 0) {
721 721
             $hash = md5($suffix);
722 722
             for ($i = 0; $i < $this->_hashedDirectoryLevel; ++$i) {
723
-                $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
723
+                $root = $root.'cache_'.substr($hash, 0, $i + 1).'/';
724 724
             }
725 725
         }
726 726
         $this->_fileName = $suffix;
727
-        $this->_file     = $root . $suffix;
727
+        $this->_file     = $root.$suffix;
728 728
     }
729 729
 
730 730
     /**
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
             $hash = md5($this->_fileName);
791 791
             $root = $this->_cacheDir;
792 792
             for ($i = 0; $i < $this->_hashedDirectoryLevel; ++$i) {
793
-                $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
793
+                $root = $root.'cache_'.substr($hash, 0, $i + 1).'/';
794 794
                 if (!(@is_dir($root))) {
795 795
                     @mkdir($root, $this->_hashedDirectoryUmask);
796 796
                 }
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
             return true;
817 817
         }
818 818
 
819
-        return $this->raiseError('Cache_Lite : Unable to write cache file : ' . $this->_file, -1);
819
+        return $this->raiseError('Cache_Lite : Unable to write cache file : '.$this->_file, -1);
820 820
     }
821 821
 
822 822
     /**
Please login to merge, or discard this patch.
class/references_handlers.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -24,34 +24,34 @@
 block discarded – undo
24 24
  */
25 25
 class references_handler
26 26
 {
27
-    public         $h_references_articles   = null;
28
-    public         $h_references_categories = null;
29
-    private static $instance                = false;
27
+	public         $h_references_articles   = null;
28
+	public         $h_references_categories = null;
29
+	private static $instance                = false;
30 30
 
31
-    /**
32
-     * Singleton
33
-     */
34
-    private function __construct()
35
-    {
36
-        $handlersNames = array('references_articles', 'references_categories');
37
-        foreach ($handlersNames as $handlerName) {
38
-            $internalName        = 'h_' . $handlerName;
39
-            $this->$internalName = xoops_getModuleHandler($handlerName, REFERENCES_DIRNAME);
40
-        }
41
-    }
31
+	/**
32
+	 * Singleton
33
+	 */
34
+	private function __construct()
35
+	{
36
+		$handlersNames = array('references_articles', 'references_categories');
37
+		foreach ($handlersNames as $handlerName) {
38
+			$internalName        = 'h_' . $handlerName;
39
+			$this->$internalName = xoops_getModuleHandler($handlerName, REFERENCES_DIRNAME);
40
+		}
41
+	}
42 42
 
43
-    /**
44
-     * Retourne l'instance unique de la clanss
45
-     *
46
-     * @return object
47
-     */
48
-    public static function getInstance()
49
-    {
50
-        static $instance;
51
-        if (null === $instance) {
52
-            $instance = new static();
53
-        }
43
+	/**
44
+	 * Retourne l'instance unique de la clanss
45
+	 *
46
+	 * @return object
47
+	 */
48
+	public static function getInstance()
49
+	{
50
+		static $instance;
51
+		if (null === $instance) {
52
+			$instance = new static();
53
+		}
54 54
 
55
-        return $instance;
56
-    }
55
+		return $instance;
56
+	}
57 57
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
     {
36 36
         $handlersNames = array('references_articles', 'references_categories');
37 37
         foreach ($handlersNames as $handlerName) {
38
-            $internalName        = 'h_' . $handlerName;
38
+            $internalName        = 'h_'.$handlerName;
39 39
             $this->$internalName = xoops_getModuleHandler($handlerName, REFERENCES_DIRNAME);
40 40
         }
41 41
     }
Please login to merge, or discard this patch.
category.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -34,21 +34,21 @@  discard block
 block discarded – undo
34 34
 
35 35
 $category_id = isset($_GET['category_id']) ? (int)$_GET['category_id'] : 0;
36 36
 if ($category_id == 0) {
37
-    header('Location: index.php', true, 301);
38
-    exit;
39
-    //references_utils::redirect('', 'index.php', 0);
37
+	header('Location: index.php', true, 301);
38
+	exit;
39
+	//references_utils::redirect('', 'index.php', 0);
40 40
 }
41 41
 // Chargement de la catégorie
42 42
 $category = null;
43 43
 $category = $h_references_categories->get($category_id);
44 44
 if (!is_object($category)) {
45
-    references_utils::redirect(_MD_REFERENCES_ERROR2, 'index.php', 4);
45
+	references_utils::redirect(_MD_REFERENCES_ERROR2, 'index.php', 4);
46 46
 }
47 47
 
48 48
 // Vérification des permissions
49 49
 $handlers = references_handler::getInstance();
50 50
 if (!$handlers->h_references_categories->userCanSeeCategory($category)) {
51
-    references_utils::redirect(_NOPERM, 'index.php', 4);
51
+	references_utils::redirect(_NOPERM, 'index.php', 4);
52 52
 }
53 53
 
54 54
 $xoopsTpl->assign('category', $category->toArray());
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 $xoTheme->addScript(REFERENCES_JS_URL . 'js/mootools.js');
65 65
 $xoTheme->addScript(REFERENCES_JS_URL . 'js/mootools-1.2-more.js');
66 66
 if (isset($xoopsConfig) && file_exists(REFERENCES_PATH . 'language/' . $xoopsConfig['language'] . '/slimbox.js')) {
67
-    $xoTheme->addScript(REFERENCES_URL . 'language/' . $xoopsConfig['language'] . '/slimbox.js');
67
+	$xoTheme->addScript(REFERENCES_URL . 'language/' . $xoopsConfig['language'] . '/slimbox.js');
68 68
 } else {
69
-    $xoTheme->addScript(REFERENCES_JS_URL . 'js/slimbox.js');
69
+	$xoTheme->addScript(REFERENCES_JS_URL . 'js/slimbox.js');
70 70
 }
71 71
 
72 72
 $categoriesSelect = $h_references_categories->getCategoriesSelect('categoriesSelect', $category->getVar('category_id'));
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 $xoopsTpl->assign('thumbsWidth', references_utils::getModuleOption('thumbs_width'));
79 79
 $xoopsTpl->assign('thumbsHeight', references_utils::getModuleOption('thumbs_height'));
80 80
 if ($limit > 0) {
81
-    $items          = array();
82
-    $items          = $h_references_articles->getRecentArticles($start, $limit, references_utils::getModuleOption('sort_field'), references_utils::getModuleOption('sort_order'), true, $category_id);
83
-    $categoryTitle  = $category->getVar('category_title');
84
-    $categoryWeight = $category->getVar('category_weight');
85
-    if (count($items) > 0) {
86
-        foreach ($items as $item) {
87
-            $xoopsTpl->append('articles', $item->toArray());
88
-        }
89
-    }
81
+	$items          = array();
82
+	$items          = $h_references_articles->getRecentArticles($start, $limit, references_utils::getModuleOption('sort_field'), references_utils::getModuleOption('sort_order'), true, $category_id);
83
+	$categoryTitle  = $category->getVar('category_title');
84
+	$categoryWeight = $category->getVar('category_weight');
85
+	if (count($items) > 0) {
86
+		foreach ($items as $item) {
87
+			$xoopsTpl->append('articles', $item->toArray());
88
+		}
89
+	}
90 90
 }
91 91
 $xoopsTpl->assign('isAdmin', references_utils::isAdmin());
92 92
 $title = $category->getVar('category_title', 'n') . ' - ' . $xoopsModule->name();
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@  discard block
 block discarded – undo
24 24
  *
25 25
  * @param integer $category_id Le numéro de la catégorie
26 26
  */
27
-require __DIR__ . '/header.php';
27
+require __DIR__.'/header.php';
28 28
 $xoopsOption['template_main'] = 'references_category.tpl';
29
-require XOOPS_ROOT_PATH . '/header.php';
29
+require XOOPS_ROOT_PATH.'/header.php';
30 30
 
31
-$baseurl = REFERENCES_URL . basename(__FILE__);
31
+$baseurl = REFERENCES_URL.basename(__FILE__);
32 32
 $limit   = references_utils::getModuleOption('items_index_page');
33 33
 $start   = $index = 0;
34 34
 
35
-$category_id = isset($_GET['category_id']) ? (int)$_GET['category_id'] : 0;
35
+$category_id = isset($_GET['category_id']) ? (int) $_GET['category_id'] : 0;
36 36
 if ($category_id == 0) {
37 37
     header('Location: index.php', true, 301);
38 38
     exit;
@@ -61,18 +61,18 @@  discard block
 block discarded – undo
61 61
 $xoopsTpl->assign('use_rss', references_utils::getModuleOption('use_rss'));
62 62
 
63 63
 // MooTools
64
-$xoTheme->addScript(REFERENCES_JS_URL . 'js/mootools.js');
65
-$xoTheme->addScript(REFERENCES_JS_URL . 'js/mootools-1.2-more.js');
66
-if (isset($xoopsConfig) && file_exists(REFERENCES_PATH . 'language/' . $xoopsConfig['language'] . '/slimbox.js')) {
67
-    $xoTheme->addScript(REFERENCES_URL . 'language/' . $xoopsConfig['language'] . '/slimbox.js');
64
+$xoTheme->addScript(REFERENCES_JS_URL.'js/mootools.js');
65
+$xoTheme->addScript(REFERENCES_JS_URL.'js/mootools-1.2-more.js');
66
+if (isset($xoopsConfig) && file_exists(REFERENCES_PATH.'language/'.$xoopsConfig['language'].'/slimbox.js')) {
67
+    $xoTheme->addScript(REFERENCES_URL.'language/'.$xoopsConfig['language'].'/slimbox.js');
68 68
 } else {
69
-    $xoTheme->addScript(REFERENCES_JS_URL . 'js/slimbox.js');
69
+    $xoTheme->addScript(REFERENCES_JS_URL.'js/slimbox.js');
70 70
 }
71 71
 
72 72
 $categoriesSelect = $h_references_categories->getCategoriesSelect('categoriesSelect', $category->getVar('category_id'));
73 73
 $xoopsTpl->assign('categoriesSelect', $categoriesSelect);
74
-$xoTheme->addStylesheet(REFERENCES_JS_URL . 'css/slimbox.css');
75
-$xoTheme->addStylesheet(REFERENCES_JS_URL . 'css/accordion.css');
74
+$xoTheme->addStylesheet(REFERENCES_JS_URL.'css/slimbox.css');
75
+$xoTheme->addStylesheet(REFERENCES_JS_URL.'css/accordion.css');
76 76
 
77 77
 // ****************************************************************************************************************************
78 78
 $xoopsTpl->assign('thumbsWidth', references_utils::getModuleOption('thumbs_width'));
@@ -89,6 +89,6 @@  discard block
 block discarded – undo
89 89
     }
90 90
 }
91 91
 $xoopsTpl->assign('isAdmin', references_utils::isAdmin());
92
-$title = $category->getVar('category_title', 'n') . ' - ' . $xoopsModule->name();
92
+$title = $category->getVar('category_title', 'n').' - '.$xoopsModule->name();
93 93
 references_utils::setMetas($title, $title);
94
-require XOOPS_ROOT_PATH . '/footer.php';
94
+require XOOPS_ROOT_PATH.'/footer.php';
Please login to merge, or discard this patch.
list.tag.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,5 +18,5 @@
 block discarded – undo
18 18
  *
19 19
  * ****************************************************************************
20 20
  */
21
-require __DIR__ . '/header.php';
22
-require XOOPS_ROOT_PATH . '/modules/tag/list.tag.php';
21
+require __DIR__.'/header.php';
22
+require XOOPS_ROOT_PATH.'/modules/tag/list.tag.php';
Please login to merge, or discard this patch.
config.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -19,27 +19,27 @@
 block discarded – undo
19 19
  * ****************************************************************************
20 20
  */
21 21
 if (!defined('REFERENCES_CACHE_PATH')) {
22
-    // Le chemin du cache (il est conseillé de le mettre en dehors de la portée du web)
23
-    define('REFERENCES_CACHE_PATH', XOOPS_UPLOAD_PATH . DIRECTORY_SEPARATOR . REFERENCES_DIRNAME . '_cache' . DIRECTORY_SEPARATOR);
22
+	// Le chemin du cache (il est conseillé de le mettre en dehors de la portée du web)
23
+	define('REFERENCES_CACHE_PATH', XOOPS_UPLOAD_PATH . DIRECTORY_SEPARATOR . REFERENCES_DIRNAME . '_cache' . DIRECTORY_SEPARATOR);
24 24
 
25
-    // Thumbs / Vignettes prefixe
26
-    define('REFERENCES_THUMBS_PREFIX', 'thumb_');        // Thumbs prefix (when thumbs are automatically created)
25
+	// Thumbs / Vignettes prefixe
26
+	define('REFERENCES_THUMBS_PREFIX', 'thumb_');        // Thumbs prefix (when thumbs are automatically created)
27 27
 
28
-    // Short text length / Longueur des textes raccourcis
29
-    define('REFERENCES_SHORTEN_TEXT', '200');        // Characters count / Nombre de caract�res
28
+	// Short text length / Longueur des textes raccourcis
29
+	define('REFERENCES_SHORTEN_TEXT', '200');        // Characters count / Nombre de caract�res
30 30
 
31
-    define('REFERENCES_METAGEN_MAX_KEYWORDS', 40);
32
-    define('REFERENCES_METAGEN_KEYWORDS_ORDER', 0);
31
+	define('REFERENCES_METAGEN_MAX_KEYWORDS', 40);
32
+	define('REFERENCES_METAGEN_KEYWORDS_ORDER', 0);
33 33
 
34
-    // Automatically fill the manual date when creating a reference ? / Remplir automatiquement la date manuelle lorsqu'on crée une référence
35
-    define('REFERENCES_AUTO_FILL_MANUAL_DATE', true);
34
+	// Automatically fill the manual date when creating a reference ? / Remplir automatiquement la date manuelle lorsqu'on crée une référence
35
+	define('REFERENCES_AUTO_FILL_MANUAL_DATE', true);
36 36
 
37
-    /**
38
-     * Si la valeur est à false, alors dans les listes de recherche, côté admin, on recherche tout ce qui contient quelque chose.
39
-     * Par exemple si on tape "a", le module trouvera "abajour" et "cartable".
40
-     * Par contre si on met cette valeur à true alors le module cherchera tout ce qui commence par ...
41
-     * Par exemple si on tape "a", lemodule trouvera "abajour" MAIS PAS "cartable"
42
-     * PAR CONTRE "%a" trouvera tout ce qui contient la lettre a
43
-     */
44
-    define('REFERENCES_EXACT_SEARCH', true);
37
+	/**
38
+	 * Si la valeur est à false, alors dans les listes de recherche, côté admin, on recherche tout ce qui contient quelque chose.
39
+	 * Par exemple si on tape "a", le module trouvera "abajour" et "cartable".
40
+	 * Par contre si on met cette valeur à true alors le module cherchera tout ce qui commence par ...
41
+	 * Par exemple si on tape "a", lemodule trouvera "abajour" MAIS PAS "cartable"
42
+	 * PAR CONTRE "%a" trouvera tout ce qui contient la lettre a
43
+	 */
44
+	define('REFERENCES_EXACT_SEARCH', true);
45 45
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@
 block discarded – undo
20 20
  */
21 21
 if (!defined('REFERENCES_CACHE_PATH')) {
22 22
     // Le chemin du cache (il est conseillé de le mettre en dehors de la portée du web)
23
-    define('REFERENCES_CACHE_PATH', XOOPS_UPLOAD_PATH . DIRECTORY_SEPARATOR . REFERENCES_DIRNAME . '_cache' . DIRECTORY_SEPARATOR);
23
+    define('REFERENCES_CACHE_PATH', XOOPS_UPLOAD_PATH.DIRECTORY_SEPARATOR.REFERENCES_DIRNAME.'_cache'.DIRECTORY_SEPARATOR);
24 24
 
25 25
     // Thumbs / Vignettes prefixe
26
-    define('REFERENCES_THUMBS_PREFIX', 'thumb_');        // Thumbs prefix (when thumbs are automatically created)
26
+    define('REFERENCES_THUMBS_PREFIX', 'thumb_'); // Thumbs prefix (when thumbs are automatically created)
27 27
 
28 28
     // Short text length / Longueur des textes raccourcis
29
-    define('REFERENCES_SHORTEN_TEXT', '200');        // Characters count / Nombre de caract�res
29
+    define('REFERENCES_SHORTEN_TEXT', '200'); // Characters count / Nombre de caract�res
30 30
 
31 31
     define('REFERENCES_METAGEN_MAX_KEYWORDS', 40);
32 32
     define('REFERENCES_METAGEN_KEYWORDS_ORDER', 0);
Please login to merge, or discard this patch.
header.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@
 block discarded – undo
19 19
  * ****************************************************************************
20 20
  */
21 21
 if (file_exists('../../mainfile.php')) {
22
-    require __DIR__ . '/../../mainfile.php';
22
+	require __DIR__ . '/../../mainfile.php';
23 23
 } elseif (file_exists('../../../mainfile.php')) {
24
-    require __DIR__ . '/../../../mainfile.php';
24
+	require __DIR__ . '/../../../mainfile.php';
25 25
 }
26 26
 require_once XOOPS_ROOT_PATH . '/modules/references/include/common.php';
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@
 block discarded – undo
19 19
  * ****************************************************************************
20 20
  */
21 21
 if (file_exists('../../mainfile.php')) {
22
-    require __DIR__ . '/../../mainfile.php';
22
+    require __DIR__.'/../../mainfile.php';
23 23
 } elseif (file_exists('../../../mainfile.php')) {
24
-    require __DIR__ . '/../../../mainfile.php';
24
+    require __DIR__.'/../../../mainfile.php';
25 25
 }
26
-require_once XOOPS_ROOT_PATH . '/modules/references/include/common.php';
26
+require_once XOOPS_ROOT_PATH.'/modules/references/include/common.php';
Please login to merge, or discard this patch.
plugins/actions/newcategory/plugins.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -25,44 +25,44 @@
 block discarded – undo
25 25
  */
26 26
 class referencesNewcategoryAction extends references_action
27 27
 {
28
-    public function registerEvents()
29
-    {
30
-        /**
31
-         * La liste des évènements traités par le plugin se présente sous la forme d'un tableau compposé comme ceci :
32
-         *
33
-         * Indice   Signification
34
-         * ----------------------
35
-         *    0        Evènement sur lequel se raccrocher (voir class/references_plugins.php::EVENT_ON_PRODUCT_CREATE
36
-         *    1        Priorité du plugin (de 1 à 5)
37
-         *    2        Script Php à inclure
38
-         *    3        Classe à instancier
39
-         *    4        Méthode à appeler
40
-         */
41
-        $events   = array();
42
-        $events[] = array(
43
-            references_plugins::EVENT_ON_CATEGORY_CREATE,
44
-            references_plugins::EVENT_PRIORITY_1,
45
-            basename(__FILE__),
46
-            __CLASS__,
47
-            'fireNewCategory'
48
-        );
28
+	public function registerEvents()
29
+	{
30
+		/**
31
+		 * La liste des évènements traités par le plugin se présente sous la forme d'un tableau compposé comme ceci :
32
+		 *
33
+		 * Indice   Signification
34
+		 * ----------------------
35
+		 *    0        Evènement sur lequel se raccrocher (voir class/references_plugins.php::EVENT_ON_PRODUCT_CREATE
36
+		 *    1        Priorité du plugin (de 1 à 5)
37
+		 *    2        Script Php à inclure
38
+		 *    3        Classe à instancier
39
+		 *    4        Méthode à appeler
40
+		 */
41
+		$events   = array();
42
+		$events[] = array(
43
+			references_plugins::EVENT_ON_CATEGORY_CREATE,
44
+			references_plugins::EVENT_PRIORITY_1,
45
+			basename(__FILE__),
46
+			__CLASS__,
47
+			'fireNewCategory'
48
+		);
49 49
 
50
-        return $events;
51
-    }
50
+		return $events;
51
+	}
52 52
 
53
-    /**
54
-     * Méthode appelée pour indiquer qu'une nouvelle catégorie de références a été créée
55
-     *
56
-     * @param object $parameters La catégorie qui vient d'être publiée
57
-     * @return void
58
-     */
59
-    public function fireNewCategory($parameters)
60
-    {
61
-        $category                = $parameters['category'];
62
-        $notification_handler    = xoops_getHandler('notification');
63
-        $params                  = array();
64
-        $params['CATEGORY_URL']  = $category->getUrl();
65
-        $params['CATEGORY_NAME'] = $category->getVar('category_title');
66
-        $notification_handler->triggerEvent('global', 0, 'new_category', $params);
67
-    }
53
+	/**
54
+	 * Méthode appelée pour indiquer qu'une nouvelle catégorie de références a été créée
55
+	 *
56
+	 * @param object $parameters La catégorie qui vient d'être publiée
57
+	 * @return void
58
+	 */
59
+	public function fireNewCategory($parameters)
60
+	{
61
+		$category                = $parameters['category'];
62
+		$notification_handler    = xoops_getHandler('notification');
63
+		$params                  = array();
64
+		$params['CATEGORY_URL']  = $category->getUrl();
65
+		$params['CATEGORY_NAME'] = $category->getVar('category_title');
66
+		$notification_handler->triggerEvent('global', 0, 'new_category', $params);
67
+	}
68 68
 }
Please login to merge, or discard this patch.
plugins/actions/twitter/twitter.php 3 patches
Indentation   +2487 added lines, -2487 removed lines patch added patch discarded remove patch
@@ -41,2493 +41,2493 @@
 block discarded – undo
41 41
  */
42 42
 class Twitter
43 43
 {
44
-    // internal constant to enable/disable debugging
45
-    const DEBUG = false;
46
-
47
-    // url for the twitter-api
48
-    const API_URL        = 'https://api.twitter.com/1';
49
-    const SECURE_API_URL = 'https://api.twitter.com';
50
-
51
-    // port for the twitter-api
52
-    const API_PORT        = 443;
53
-    const SECURE_API_PORT = 443;
54
-
55
-    // current version
56
-    const VERSION = '2.0.1';
57
-
58
-    /**
59
-     * A cURL instance
60
-     *
61
-     * @var    resource
62
-     */
63
-    private $curl;
64
-
65
-    /**
66
-     * The consumer key
67
-     *
68
-     * @var    string
69
-     */
70
-    private $consumerKey;
71
-
72
-    /**
73
-     * The consumer secret
74
-     *
75
-     * @var    string
76
-     */
77
-    private $consumerSecret;
78
-
79
-    /**
80
-     * The oAuth-token
81
-     *
82
-     * @var    string
83
-     */
84
-    private $oAuthToken = '';
85
-
86
-    /**
87
-     * The oAuth-token-secret
88
-     *
89
-     * @var    string
90
-     */
91
-    private $oAuthTokenSecret = '';
92
-
93
-    /**
94
-     * The timeout
95
-     *
96
-     * @var    int
97
-     */
98
-    private $timeOut = 60;
99
-
100
-    /**
101
-     * The user agent
102
-     *
103
-     * @var    string
104
-     */
105
-    private $userAgent;
106
-
107
-    // class methods
108
-    /**
109
-     * Default constructor
110
-     *
111
-     *
112
-     * @param    string $consumerKey    The consumer key to use.
113
-     * @param    string $consumerSecret The consumer secret to use.
114
-     */
115
-    public function __construct($consumerKey, $consumerSecret)
116
-    {
117
-        $this->setConsumerKey($consumerKey);
118
-        $this->setConsumerSecret($consumerSecret);
119
-    }
120
-
121
-    /**
122
-     * Default destructor
123
-     *
124
-     * @return    void
125
-     */
126
-    public function __destruct()
127
-    {
128
-        if ($this->curl != null) curl_close($this->curl);
129
-    }
130
-
131
-    /**
132
-     * Format the parameters as a querystring
133
-     *
134
-     * @return    string
135
-     * @param    array $parameters
136
-     */
137
-    private function buildQuery(array $parameters)
138
-    {
139
-        // no parameters?
140
-        if (empty($parameters)) return '';
141
-
142
-        // encode the keys
143
-        $keys = self::urlencode_rfc3986(array_keys($parameters));
144
-
145
-        // encode the values
146
-        $values = self::urlencode_rfc3986(array_values($parameters));
147
-
148
-        // reset the parameters
149
-        $parameters = array_combine($keys, $values);
150
-
151
-        // sort parameters by key
152
-        uksort($parameters, 'strcmp');
153
-
154
-        // loop parameters
155
-        foreach ($parameters as $key => $value) {
156
-            // sort by value
157
-            if (is_array($value)) $parameters[$key] = natsort($value);
158
-        }
159
-
160
-        // process parameters
161
-        foreach ($parameters as $key => $value) $chunks[] = $key . '=' . str_replace('%25', '%', $value);
162
-
163
-        // return
164
-        return implode('&', $chunks);
165
-    }
166
-
167
-    /**
168
-     * All OAuth 1.0 requests use the same basic algorithm for creating a signature base string and a signature.
169
-     * The signature base string is composed of the HTTP method being used, followed by an ampersand ("&") and then the URL-encoded base URL being accessed,
170
-     * complete with path (but not query parameters), followed by an ampersand ("&").
171
-     * Then, you take all query parameters and POST body parameters (when the POST body is of the URL-encoded type, otherwise the POST body is ignored),
172
-     * including the OAuth parameters necessary for negotiation with the request at hand, and sort them in lexicographical order by first parameter name and
173
-     * then parameter value (for duplicate parameters), all the while ensuring that both the key and the value for each parameter are URL encoded in isolation.
174
-     * Instead of using the equals ("=") sign to mark the key/value relationship, you use the URL-encoded form of "%3D". Each parameter is then joined by the
175
-     * URL-escaped ampersand sign, "%26".
176
-     *
177
-     * @return    string
178
-     * @param    string $url
179
-     * @param    string $method
180
-     * @param    array  $parameters
181
-     */
182
-    private function calculateBaseString($url, $method, array $parameters)
183
-    {
184
-        // redefine
185
-        $url        = (string)$url;
186
-        $parameters = (array)$parameters;
187
-
188
-        // init var
189
-        $pairs  = array();
190
-        $chunks = array();
191
-
192
-        // sort parameters by key
193
-        uksort($parameters, 'strcmp');
194
-
195
-        // loop parameters
196
-        foreach ($parameters as $key => $value) {
197
-            // sort by value
198
-            if (is_array($value)) $parameters[$key] = natsort($value);
199
-        }
200
-
201
-        // process queries
202
-        foreach ($parameters as $key => $value) {
203
-            $chunks[] = self::urlencode_rfc3986($key) . '%3D' . self::urlencode_rfc3986($value);
204
-        }
205
-
206
-        // buils base
207
-        $base = $method . '&';
208
-        $base .= urlencode($url) . '&';
209
-        $base .= implode('%26', $chunks);
210
-
211
-        // return
212
-        return $base;
213
-    }
214
-
215
-    /**
216
-     * Build the Authorization header
217
-     * @later: fix me
218
-     *
219
-     *
220
-     * @param    array $parameters
221
-     * @param null     $url
222
-     * @return string
223
-     */
224
-    private function calculateHeader(array $parameters, $url = null)
225
-    {
226
-        // redefine
227
-        $url = (string)$url;
228
-
229
-        // divide into parts
230
-        $parts = parse_url($url);
231
-
232
-        // init var
233
-        $chunks = array();
234
-
235
-        // process queries
236
-        foreach ($parameters as $key => $value) $chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key) . '="' . self::urlencode_rfc3986($value) . '"');
237
-
238
-        // build return
239
-        $return = 'Authorization: OAuth realm="' . $parts['scheme'] . '://' . $parts['host'] . $parts['path'] . '", ';
240
-        $return .= implode(',', $chunks);
241
-
242
-        // prepend name and OAuth part
243
-        return $return;
244
-    }
245
-
246
-    /**
247
-     * Make an call to the oAuth
248
-     * @todo    refactor me
249
-     *
250
-     *
251
-     * @param    string $method
252
-     * @param array     $parameters [optional] $parameters
253
-     * @return array
254
-     * @throws TwitterException
255
-     */
256
-    private function doOAuthCall($method, array $parameters = null)
257
-    {
258
-        // redefine
259
-        $method = (string)$method;
260
-
261
-        // append default parameters
262
-        $parameters['oauth_consumer_key']     = $this->getConsumerKey();
263
-        $parameters['oauth_nonce']            = md5(microtime() . rand());
264
-        $parameters['oauth_timestamp']        = time();
265
-        $parameters['oauth_signature_method'] = 'HMAC-SHA1';
266
-        $parameters['oauth_version']          = '1.0';
267
-
268
-        // calculate the base string
269
-        $base = $this->calculateBaseString(self::SECURE_API_URL . '/oauth/' . $method, 'POST', $parameters);
270
-
271
-        // add sign into the parameters
272
-        $parameters['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret() . '&' . $this->getOAuthTokenSecret(), $base);
273
-
274
-        // calculate header
275
-        $header = $this->calculateHeader($parameters, self::SECURE_API_URL . '/oauth/' . $method);
276
-
277
-        // set options
278
-        $options[CURLOPT_URL]            = self::SECURE_API_URL . '/oauth/' . $method;
279
-        $options[CURLOPT_PORT]           = self::SECURE_API_PORT;
280
-        $options[CURLOPT_USERAGENT]      = $this->getUserAgent();
281
-        $options[CURLOPT_FOLLOWLOCATION] = true;
282
-        $options[CURLOPT_RETURNTRANSFER] = true;
283
-        $options[CURLOPT_TIMEOUT]        = (int)$this->getTimeOut();
284
-        $options[CURLOPT_SSL_VERIFYPEER] = false;
285
-        $options[CURLOPT_SSL_VERIFYHOST] = false;
286
-        $options[CURLOPT_HTTPHEADER]     = array('Expect:');
287
-        $options[CURLOPT_POST]           = 1;
288
-        $options[CURLOPT_POSTFIELDS]     = $this->buildQuery($parameters);
289
-
290
-        // init
291
-        if ($this->curl == null) $this->curl = curl_init();
292
-
293
-        // set options
294
-        curl_setopt_array($this->curl, $options);
295
-
296
-        // execute
297
-        $response = curl_exec($this->curl);
298
-        $headers  = curl_getinfo($this->curl);
299
-
300
-        // fetch errors
301
-        $errorNumber  = curl_errno($this->curl);
302
-        $errorMessage = curl_error($this->curl);
303
-
304
-        // error?
305
-        if ($errorNumber != '') throw new TwitterException($errorMessage, $errorNumber);
306
-
307
-        // init var
308
-        $return = array();
309
-
310
-        // parse the string
311
-        parse_str($response, $return);
312
-
313
-        // return
314
-        return $return;
315
-    }
316
-
317
-    /**
318
-     * Make the call
319
-     *
320
-     *
321
-     * @param    string $url
322
-     * @param array     $parameters
323
-     * @param bool      $authenticate
324
-     * @param string    $method
325
-     * @param null      $filePath
326
-     * @param bool      $expectJSON
327
-     * @return string
328
-     * @throws TwitterException
329
-     * @internal param $array [optiona] $aParameters
330
-     * @internal param $bool [optional] $authenticate
331
-     * @internal param $bool [optional] $usePost
332
-     */
333
-    private function doCall($url, array $parameters = null, $authenticate = false, $method = 'GET', $filePath = null, $expectJSON = true)
334
-    {
335
-        // allowed methods
336
-        $allowedMethods = array('GET', 'POST');
337
-
338
-        // redefine
339
-        $url          = (string)$url;
340
-        $parameters   = (array)$parameters;
341
-        $authenticate = (bool)$authenticate;
342
-        $method       = (string)$method;
343
-        $expectJSON   = (bool)$expectJSON;
344
-
345
-        // validate method
346
-        if (!in_array($method, $allowedMethods)) throw new TwitterException('Unknown method (' . $method . '). Allowed methods are: ' . implode(', ', $allowedMethods));
347
-
348
-        // append default parameters
349
-        $oauth['oauth_consumer_key']     = $this->getConsumerKey();
350
-        $oauth['oauth_nonce']            = md5(microtime() . rand());
351
-        $oauth['oauth_timestamp']        = time();
352
-        $oauth['oauth_token']            = $this->getOAuthToken();
353
-        $oauth['oauth_signature_method'] = 'HMAC-SHA1';
354
-        $oauth['oauth_version']          = '1.0';
355
-
356
-        // set data
357
-        $data = $oauth;
358
-        if (!empty($parameters)) $data = array_merge($data, $parameters);
359
-
360
-        // calculate the base string
361
-        $base = $this->calculateBaseString(self::API_URL . '/' . $url, $method, $data);
362
-
363
-        // add sign into the parameters
364
-        $oauth['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret() . '&' . $this->getOAuthTokenSecret(), $base);
365
-
366
-        $headers[] = $this->calculateHeader($oauth, self::API_URL . '/' . $url);
367
-        $headers[] = 'Expect:';
368
-
369
-        // based on the method, we should handle the parameters in a different way
370
-        if ($method === 'POST') {
371
-            // file provided?
372
-            if ($filePath != null) {
373
-                // build a boundary
374
-                $boundary = md5(time());
375
-
376
-                // process file
377
-                $fileInfo = pathinfo($filePath);
378
-
379
-                // set mimeType
380
-                $mimeType = 'application/octet-stream';
381
-                if ($fileInfo['extension'] === 'jpg' || $fileInfo['extension'] === 'jpeg') {
382
-                    $mimeType = 'image/jpeg';
383
-                } elseif ($fileInfo['extension'] === 'gif') $mimeType = 'image/gif';
384
-                elseif ($fileInfo['extension'] === 'png') $mimeType = 'image/png';
385
-
386
-                // init var
387
-                $content = '--' . $boundary . "\r\n";
388
-
389
-                // set file
390
-                $content = 'Content-Disposition: form-data; name="image";filename="' . $fileInfo['basename'] . '"' . "\r\n" . 'Content-Type: ' . $mimeType . "\r\n\r\n" . file_get_contents($filePath) . "\r\n--" . $boundary . "\r\n";
391
-
392
-                // build headers
393
-                $headers[] = 'Content-Type: multipart/form-data; boundary=' . $boundary;
394
-                $headers[] = 'Content-Length: ' . strlen($content);
395
-
396
-                // set content
397
-                $options[CURLOPT_POSTFIELDS] = $content;
398
-            } // no file
399
-            else $options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters);
400
-
401
-            // enable post
402
-            $options[CURLOPT_POST] = 1;
403
-        } else {
404
-            // add the parameters into the querystring
405
-            if (!empty($parameters)) $url .= '?' . $this->buildQuery($parameters);
406
-        }
407
-
408
-        // set options
409
-        $options[CURLOPT_URL]            = self::API_URL . '/' . $url;
410
-        $options[CURLOPT_PORT]           = self::API_PORT;
411
-        $options[CURLOPT_USERAGENT]      = $this->getUserAgent();
412
-        $options[CURLOPT_FOLLOWLOCATION] = true;
413
-        $options[CURLOPT_RETURNTRANSFER] = true;
414
-        $options[CURLOPT_TIMEOUT]        = (int)$this->getTimeOut();
415
-        $options[CURLOPT_SSL_VERIFYPEER] = false;
416
-        $options[CURLOPT_SSL_VERIFYHOST] = false;
417
-        $options[CURLOPT_HTTP_VERSION]   = CURL_HTTP_VERSION_1_1;
418
-        $options[CURLOPT_HTTPHEADER]     = $headers;
419
-
420
-        // init
421
-        if ($this->curl == null) $this->curl = curl_init();
422
-
423
-        // set options
424
-        curl_setopt_array($this->curl, $options);
425
-
426
-        // execute
427
-        $response = curl_exec($this->curl);
428
-        $headers  = curl_getinfo($this->curl);
429
-
430
-        // fetch errors
431
-        $errorNumber  = curl_errno($this->curl);
432
-        $errorMessage = curl_error($this->curl);
433
-
434
-        // we don't expext JSON, return the response
435
-        if (!$expectJSON) return $response;
436
-
437
-        // replace ids with their string values, added because of some PHP-version can't handle these large values
438
-        $response = preg_replace('/id":(\d+)/', 'id":"\1"', $response);
439
-
440
-        // we expect JSON, so decode it
441
-        $json = @json_decode($response, true);
442
-
443
-        // validate JSON
444
-        if ($json === null) {
445
-            // should we provide debug information
446
-            if (self::DEBUG) {
447
-                // make it output proper
448
-                echo '<pre>';
449
-
450
-                // dump the header-information
451
-                var_dump($headers);
452
-
453
-                // dump the error
454
-                var_dump($errorMessage);
455
-
456
-                // dump the raw response
457
-                var_dump($response);
458
-
459
-                // end proper format
460
-                echo '</pre>';
461
-            }
462
-
463
-            // throw exception
464
-            throw new TwitterException('Invalid response.');
465
-        }
466
-
467
-        // any errors
468
-        if (isset($json['errors'])) {
469
-            // should we provide debug information
470
-            if (self::DEBUG) {
471
-                // make it output proper
472
-                echo '<pre>';
473
-
474
-                // dump the header-information
475
-                var_dump($headers);
476
-
477
-                // dump the error
478
-                var_dump($errorMessage);
479
-
480
-                // dump the raw response
481
-                var_dump($response);
482
-
483
-                // end proper format
484
-                echo '</pre>';
485
-            }
486
-
487
-            // throw exception
488
-            if (isset($json['errors'][0]['message'])) {
489
-                throw new TwitterException($json['errors'][0]['message']);
490
-            } else throw new TwitterException('Invalid response.');
491
-        }
492
-
493
-        // any error
494
-        if (isset($json['error'])) {
495
-            // should we provide debug information
496
-            if (self::DEBUG) {
497
-                // make it output proper
498
-                echo '<pre>';
499
-
500
-                // dump the header-information
501
-                var_dump($headers);
502
-
503
-                // dump the raw response
504
-                var_dump($response);
505
-
506
-                // end proper format
507
-                echo '</pre>';
508
-            }
509
-
510
-            // throw exception
511
-            throw new TwitterException($json['error']);
512
-        }
513
-
514
-        // return
515
-        return $json;
516
-    }
517
-
518
-    /**
519
-     * Get the consumer key
520
-     *
521
-     * @return    string
522
-     */
523
-    private function getConsumerKey()
524
-    {
525
-        return $this->consumerKey;
526
-    }
527
-
528
-    /**
529
-     * Get the consumer secret
530
-     *
531
-     * @return    string
532
-     */
533
-    private function getConsumerSecret()
534
-    {
535
-        return $this->consumerSecret;
536
-    }
537
-
538
-    /**
539
-     * Get the oAuth-token
540
-     *
541
-     * @return    string
542
-     */
543
-    private function getOAuthToken()
544
-    {
545
-        return $this->oAuthToken;
546
-    }
547
-
548
-    /**
549
-     * Get the oAuth-token-secret
550
-     *
551
-     * @return    string
552
-     */
553
-    private function getOAuthTokenSecret()
554
-    {
555
-        return $this->oAuthTokenSecret;
556
-    }
557
-
558
-    /**
559
-     * Get the timeout
560
-     *
561
-     * @return    int
562
-     */
563
-    public function getTimeOut()
564
-    {
565
-        return (int)$this->timeOut;
566
-    }
567
-
568
-    /**
569
-     * Get the useragent that will be used. Our version will be prepended to yours.
570
-     * It will look like: "PHP Twitter/<version> <your-user-agent>"
571
-     *
572
-     * @return    string
573
-     */
574
-    public function getUserAgent()
575
-    {
576
-        return (string)'PHP Twitter/' . self::VERSION . ' ' . $this->userAgent;
577
-    }
578
-
579
-    /**
580
-     * Set the consumer key
581
-     *
582
-     * @return    void
583
-     * @param    string $key The consumer key to use.
584
-     */
585
-    private function setConsumerKey($key)
586
-    {
587
-        $this->consumerKey = (string)$key;
588
-    }
589
-
590
-    /**
591
-     * Set the consumer secret
592
-     *
593
-     * @return    void
594
-     * @param    string $secret The consumer secret to use.
595
-     */
596
-    private function setConsumerSecret($secret)
597
-    {
598
-        $this->consumerSecret = (string)$secret;
599
-    }
600
-
601
-    /**
602
-     * Set the oAuth-token
603
-     *
604
-     * @return    void
605
-     * @param    string $token The token to use.
606
-     */
607
-    public function setOAuthToken($token)
608
-    {
609
-        $this->oAuthToken = (string)$token;
610
-    }
611
-
612
-    /**
613
-     * Set the oAuth-secret
614
-     *
615
-     * @return    void
616
-     * @param    string $secret The secret to use.
617
-     */
618
-    public function setOAuthTokenSecret($secret)
619
-    {
620
-        $this->oAuthTokenSecret = (string)$secret;
621
-    }
622
-
623
-    /**
624
-     * Set the timeout
625
-     *
626
-     * @return    void
627
-     * @param    int $seconds The timeout in seconds
628
-     */
629
-    public function setTimeOut($seconds)
630
-    {
631
-        $this->timeOut = (int)$seconds;
632
-    }
633
-
634
-    /**
635
-     * Get the useragent that will be used. Our version will be prepended to yours.
636
-     * It will look like: "PHP Twitter/<version> <your-user-agent>"
637
-     *
638
-     * @return    void
639
-     * @param    string $userAgent Your user-agent, it should look like <app-name>/<app-version>
640
-     */
641
-    public function setUserAgent($userAgent)
642
-    {
643
-        $this->userAgent = (string)$userAgent;
644
-    }
645
-
646
-    /**
647
-     * Build the signature for the data
648
-     *
649
-     * @return    string
650
-     * @param    string $key  The key to use for signing.
651
-     * @param    string $data The data that has to be signed.
652
-     */
653
-    private function hmacsha1($key, $data)
654
-    {
655
-        return base64_encode(hash_hmac('SHA1', $data, $key, true));
656
-    }
657
-
658
-    /**
659
-     * URL-encode method for internatl use
660
-     *
661
-     * @return    string
662
-     * @param    mixed $value The value to encode.
663
-     */
664
-    private static function urlencode_rfc3986($value)
665
-    {
666
-        if (is_array($value)) {
667
-            return array_map(array('Twitter', 'urlencode_rfc3986'), $value);
668
-        } else {
669
-            $search  = array('+', ' ', '%7E', '%');
670
-            $replace = array('%20', '%20', '~', '%25');
671
-
672
-            return str_replace($search, $replace, urlencode($value));
673
-        }
674
-    }
675
-
676
-
677
-    // Timeline resources
678
-    /**
679
-     * Returns the 20 most recent statuses from non-protected users who have set a custom user icon.
680
-     * The public timeline is cached for 60 seconds and requesting it more often than that is unproductive and a waste of resources.
681
-     *
682
-     * @return    array
683
-     * @param    bool [optional] $skipUser    When true each tweet returned in a timeline will not contain an entire user object. Instead, the user node will contain only an id element to indicate the numerical ID of the Twitter user that set the status.
684
-     */
685
-    public function statusesPublicTimeline($skipUser = false)
686
-    {
687
-        // redefine
688
-        $skipUser = (bool)$skipUser;
689
-
690
-        // build parameters
691
-        $parameters = array();
692
-        if ($skipUser) $parameters['skip_user'] = 'true';
693
-
694
-        // make the call
695
-        return (array)$this->doCall('statuses/public_timeline.json', $parameters);
696
-    }
697
-
698
-    /**
699
-     * Returns the 20 most recent statuses posted by the authenticating user and that user's friends. This is the equivalent of /timeline/home on the Web.
700
-     *
701
-     * @return    array
702
-     * @param    string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
703
-     * @param    string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
704
-     * @param    int    [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
705
-     * @param    int    [optional] $page            Specifies the page of results to retrieve.
706
-     * @param    bool   [optional] $skipUser    When true each tweet returned in a timeline will not contain an entire user object. Instead, the user node will contain only an id element to indicate the numerical ID of the Twitter user that set the status.
707
-     */
708
-    public function statusesHomeTimeline($sinceId = null, $maxId = null, $count = null, $page = null, $skipUser = false)
709
-    {
710
-        // redefine
711
-        $skipUser = (bool)$skipUser;
712
-
713
-        // build parameters
714
-        $parameters = array();
715
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
716
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
717
-        if ($count != null) $parameters['count'] = (int)$count;
718
-        if ($page != null) $parameters['page'] = (int)$page;
719
-        if ($skipUser) $parameters['skip_user'] = 'true';
720
-
721
-        // make the call
722
-        return (array)$this->doCall('statuses/home_timeline.json', $parameters, true);
723
-    }
724
-
725
-    /**
726
-     * Returns the 20 most recent statuses, including retweets, posted by the authenticating user and that user's friends.
727
-     * This is the equivalent of /timeline/home on the Web.
728
-     *
729
-     * Usage note: This home_timeline call is identical to statuses/friends_timeline, except that home_timeline also contains retweets, while statuses/friends_timeline does not for backwards compatibility reasons.
730
-     * In a future version of the API, statuses/friends_timeline will be deprected and replaced by home_timeline.
731
-     *
732
-     * @return    array
733
-     * @param    string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
734
-     * @param    string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
735
-     * @param    int    [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
736
-     * @param    int    [optional] $page            Specifies the page of results to retrieve.
737
-     * @param    bool   [optional] $skipUser    When true each tweet returned in a timeline will not contain an entire user object. Instead, the user node will contain only an id element to indicate the numerical ID of the Twitter user that set the status.
738
-     */
739
-    public function statusesFriendsTimeline($sinceId = null, $maxId = null, $count = null, $page = null, $skipUser = false)
740
-    {
741
-        // redefine
742
-        $skipUser = (bool)$skipUser;
743
-
744
-        // build parameters
745
-        $parameters = array();
746
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
747
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
748
-        if ($count != null) $parameters['count'] = (int)$count;
749
-        if ($page != null) $parameters['page'] = (int)$page;
750
-        if ($skipUser) $parameters['skip_user'] = 'true';
751
-
752
-        // make the call
753
-        return (array)$this->doCall('statuses/friends_timeline.json', $parameters, true);
754
-    }
755
-
756
-    /**
757
-     * Returns the 20 most recent statuses posted from the authenticating user. It's also possible to request another user's timeline via the id parameter.
758
-     * This is the equivalent of the Web / page for your own user, or the profile page for a third party.
759
-     *
760
-     * For backwards compatibility reasons, retweets are stripped out of the user_timeline when calling in XML or JSON (they appear with 'RT' in RSS and Atom).
761
-     * If you'd like them included, you can merge them in from statuses retweeted_by_me.
762
-     *
763
-     * @return    array
764
-     * @param    string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
765
-     * @param    string [optional] $userId        Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
766
-     * @param    string [optional] $screenName    Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
767
-     * @param    string [optional] $sinceId        Returns results with an ID greater than (that is, more recent than) the specified ID.
768
-     * @param    string [optional] $maxId            Returns results with an ID less than (that is, older than) or equal to the specified ID.
769
-     * @param    int    [optional] $count            Specifies the number of records to retrieve. May not be greater than 200.
770
-     * @param    int    [optional] $page                Specifies the page of results to retrieve.
771
-     * @param    bool   [optional] $skipUser        When true each tweet returned in a timeline will not contain an entire user object. Instead, the user node will contain only an id element to indicate the numerical ID of the Twitter user that set the status.
772
-     */
773
-    public function statusesUserTimeline($id = null, $userId = null, $screenName = null, $sinceId = null, $maxId = null, $count = null, $page = null, $skipUser = false)
774
-    {
775
-        // redefine
776
-        $skipUser = (bool)$skipUser;
777
-
778
-        // build parameters
779
-        $parameters = array();
780
-        if ($id != null) $parameters['id'] = (string)$id;
781
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
782
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
783
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
784
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
785
-        if ($count != null) $parameters['count'] = (int)$count;
786
-        if ($page != null) $parameters['page'] = (int)$page;
787
-        if ($skipUser) $parameters['skip_user'] = 'true';
788
-
789
-        // make the call
790
-        return (array)$this->doCall('statuses/user_timeline.json', $parameters, true);
791
-    }
792
-
793
-    /**
794
-     * Returns the 20 most recent mentions (status containing @username) for the authenticating user.
795
-     *
796
-     *
797
-     * @param null $sinceId
798
-     * @param null $maxId
799
-     * @param null $count
800
-     * @param null $page
801
-     * @return array
802
-     * @throws TwitterException
803
-     * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
804
-     * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
805
-     * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
806
-     * @internal param $int [optional] $page            Specifies the page of results to retrieve.
807
-     */
808
-    public function statusesMentions($sinceId = null, $maxId = null, $count = null, $page = null)
809
-    {
810
-        // validate
811
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
812
-
813
-        // build parameters
814
-        $parameters = array();
815
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
816
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
817
-        if ($count != null) $parameters['count'] = (int)$count;
818
-        if ($page != null) $parameters['page'] = (int)$page;
819
-
820
-        // make the call
821
-        return (array)$this->doCall('statuses/mentions.json', $parameters);
822
-    }
823
-
824
-    /**
825
-     * Returns the 20 most recent retweets posted by the authenticating user.
826
-     *
827
-     *
828
-     * @param null $sinceId
829
-     * @param null $maxId
830
-     * @param null $count
831
-     * @param null $page
832
-     * @return array
833
-     * @throws TwitterException
834
-     * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
835
-     * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
836
-     * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
837
-     * @internal param $int [optional] $page            Specifies the page of results to retrieve.
838
-     */
839
-    public function statusesRetweetedByMe($sinceId = null, $maxId = null, $count = null, $page = null)
840
-    {
841
-        // validate
842
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
843
-
844
-        // build parameters
845
-        $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;
850
-
851
-        // make the call
852
-        return (array)$this->doCall('statuses/retweeted_by_me.json', $parameters);
853
-    }
854
-
855
-    /**
856
-     * Returns the 20 most recent retweets posted by the authenticating user's friends.
857
-     *
858
-     *
859
-     * @param null $sinceId
860
-     * @param null $maxId
861
-     * @param null $count
862
-     * @param null $page
863
-     * @return array
864
-     * @throws TwitterException
865
-     * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
866
-     * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
867
-     * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
868
-     * @internal param $int [optional] $page            Specifies the page of results to retrieve.
869
-     */
870
-    public function statusesRetweetedToMe($sinceId = null, $maxId = null, $count = null, $page = null)
871
-    {
872
-        // validate
873
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
874
-
875
-        // build parameters
876
-        $parameters = array();
877
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
878
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
879
-        if ($count != null) $parameters['count'] = (int)$count;
880
-        if ($page != null) $parameters['page'] = (int)$page;
881
-
882
-        // make the call
883
-        return (array)$this->doCall('statuses/retweeted_by_me.json', $parameters);
884
-    }
885
-
886
-
887
-    // Tweets resources
888
-    /**
889
-     * Returns the 20 most recent tweets of the authenticated user that have been retweeted by others.
890
-     *
891
-     *
892
-     * @param null $sinceId
893
-     * @param null $maxId
894
-     * @param null $count
895
-     * @param null $page
896
-     * @return array
897
-     * @throws TwitterException
898
-     * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
899
-     * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
900
-     * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
901
-     * @internal param $int [optional] $page            Specifies the page of results to retrieve.
902
-     */
903
-    public function statusesReweetsOfMe($sinceId = null, $maxId = null, $count = null, $page = null)
904
-    {
905
-        // validate
906
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
907
-
908
-        // build parameters
909
-        $parameters = array();
910
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
911
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
912
-        if ($count != null) $parameters['count'] = (int)$count;
913
-        if ($page != null) $parameters['page'] = (int)$page;
914
-
915
-        // make the call
916
-        return (array)$this->doCall('statuses/retweets_of_me.json', $parameters);
917
-    }
918
-
919
-    /**
920
-     * Returns a single status, specified by the id parameter below. The status's author will be returned inline.
921
-     *
922
-     * @return    array
923
-     * @param    string $id The numerical ID of the desired status.
924
-     */
925
-    public function statusesShow($id)
926
-    {
927
-        // build parameters
928
-        $parameters['id'] = (string)$id;
929
-
930
-        // make the call
931
-        return (array)$this->doCall('statuses/show.json', $parameters);
932
-    }
933
-
934
-    /**
935
-     * Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
936
-     *
937
-     * @return    array
938
-     * @param    string $status The text of your status update, up to 140 characters. URL encode as necessary.
939
-     * @param           string  [optional] $inReplyToStatusId        The ID of an existing status that the update is in reply to.
940
-     * @param           float   [optional] $lat                    The location's latitude that this tweet refers to.
941
-     * @param           float   [optional] $long                    The location's longitude that this tweet refers to.
942
-     * @param           string  [optional] $placeId                A place in the world. These IDs can be retrieved from geo/reverse_geocode.
943
-     * @param           bool    [optional] $displayCoordinates        Whether or not to put a pin on the exact coordinates a tweet has been sent from.
944
-     */
945
-    public function statusesUpdate($status, $inReplyToStatusId = null, $lat = null, $long = null, $placeId = null, $displayCoordinates = false)
946
-    {
947
-        // build parameters
948
-        $parameters['status'] = (string)$status;
949
-        if ($inReplyToStatusId != null) $parameters['in_reply_to_status_id'] = (string)$inReplyToStatusId;
950
-        if ($lat != null) $parameters['lat'] = (float)$lat;
951
-        if ($long != null) $parameters['long'] = (float)$long;
952
-        if ($placeId != null) $parameters['place_id'] = (string)$placeId;
953
-        if ($displayCoordinates) $parameters['display_coordinates'] = 'true';
954
-
955
-        // make the call
956
-        return (array)$this->doCall('statuses/update.json', $parameters, true, 'POST');
957
-    }
958
-
959
-    /**
960
-     * Destroys the status specified by the required ID parameter.
961
-     * Usage note: The authenticating user must be the author of the specified status.
962
-     *
963
-     * @return    bool
964
-     * @param    string $id The numerical ID of the desired status.
965
-     */
966
-    public function statusesDestroy($id)
967
-    {
968
-        // build parameters
969
-        $parameters['id'] = (string)$id;
970
-
971
-        // make the call
972
-        return (array)$this->doCall('statuses/destroy.json', $parameters, true, 'POST');
973
-    }
974
-
975
-    /**
976
-     * Retweets a tweet. Returns the original tweet with retweet details embedded.
977
-     *
978
-     * @return    array
979
-     * @param    string $id The numerical ID of the desired status.
980
-     */
981
-    public function statusesRetweet($id)
982
-    {
983
-        // make the call
984
-        return (array)$this->doCall('statuses/retweet/' . $id . '.json', null, true, 'POST');
985
-    }
986
-
987
-    /**
988
-     * Returns up to 100 of the first retweets of a given tweet.
989
-     *
990
-     *
991
-     * @param    string $id The numerical ID of the desired status.
992
-     * @param           int [optional] $count    Specifies the number of records to retrieve. May not be greater than 100.
993
-     * @return array
994
-     * @throws TwitterException
995
-     */
996
-    public function statusesRetweets($id, $count = null)
997
-    {
998
-        // validate
999
-        if ($count != null && $count > 100) throw new TwitterException('Count may not be greater than 100.');
1000
-
1001
-        // build parameters
1002
-        $parameters = null;
1003
-        if ($count != null) $parameters['count'] = (int)$count;
1004
-
1005
-        // make the call
1006
-        return (array)$this->doCall('statuses/retweets/' . $id . '.json', $parameters);
1007
-    }
1008
-
1009
-    /**
1010
-     * Show user objects of up to 100 members who retweeted the status.
1011
-     *
1012
-     *
1013
-     * @param    string $id The numerical ID of the desired status.
1014
-     * @param null      $count
1015
-     * @param null      $page
1016
-     * @return array
1017
-     * @throws TwitterException
1018
-     * @internal param $int [optional] $count    Specifies the number of records to retrieve. May not be greater than 200.
1019
-     * @internal param $int [optional] $page        Specifies the page of results to retrieve.
1020
-     */
1021
-    public function statusesIdRetweetedBy($id, $count = null, $page = null)
1022
-    {
1023
-        // validate
1024
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1025
-
1026
-        // build parameters
1027
-        $parameters = null;
1028
-        if ($count != null) $parameters['count'] = (int)$count;
1029
-        if ($page != null) $parameters['page'] = (int)$page;
1030
-
1031
-        // make the call
1032
-        return (array)$this->doCall('statuses/' . (string)$id . '/retweeted_by.json', $parameters, true);
1033
-    }
1034
-
1035
-    /**
1036
-     * Show user ids of up to 100 users who retweeted the status.
1037
-     *
1038
-     *
1039
-     * @param    string $id The numerical ID of the desired status.
1040
-     * @param null      $count
1041
-     * @param null      $page
1042
-     * @return array
1043
-     * @throws TwitterException
1044
-     * @internal param $int [optional] $count    Specifies the number of records to retrieve. May not be greater than 200.
1045
-     * @internal param $int [optional] $page        Specifies the page of results to retrieve.
1046
-     */
1047
-    public function statusesIdRetweetedByIds($id, $count = null, $page = null)
1048
-    {
1049
-        // validate
1050
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1051
-
1052
-        // build parameters
1053
-        $parameters = null;
1054
-        if ($count != null) $parameters['count'] = (int)$count;
1055
-        if ($page != null) $parameters['page'] = (int)$page;
1056
-
1057
-        // make the call
1058
-        return (array)$this->doCall('statuses/' . (string)$id . '/retweeted_by/ids.json', $parameters, true);
1059
-    }
1060
-
1061
-
1062
-    // User resources
1063
-    /**
1064
-     * Returns extended information of a given user, specified by ID or screen name as per the required id parameter.
1065
-     * The author's most recent status will be returned inline.
1066
-     *
1067
-     *
1068
-     * @param null $id
1069
-     * @param null $userId
1070
-     * @param null $screenName
1071
-     * @return array
1072
-     * @throws TwitterException
1073
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1074
-     * @internal param $string [optional] $userId        Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1075
-     * @internal param $string [optional] $screenName    Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1076
-     */
1077
-    public function usersShow($id = null, $userId = null, $screenName = null)
1078
-    {
1079
-        // validate
1080
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1081
-
1082
-        // build parameters
1083
-        if ($id != null) $parameters['id'] = (string)$id;
1084
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1085
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1086
-
1087
-        // make the call
1088
-        return (array)$this->doCall('users/show.json', $parameters);
1089
-    }
1090
-
1091
-    /**
1092
-     * Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two.
1093
-     * The author's most recent status (if the authenticating user has permission) will be returned inline.
1094
-     *
1095
-     *
1096
-     * @param null $userIds
1097
-     * @param null $screenNames
1098
-     * @return array
1099
-     * @throws TwitterException
1100
-     * @internal param $mixed [optional] $userIds        A comma separated list of user IDs, up to 100 in total.
1101
-     * @internal param $mixed [optional] $screenNames    A comma separated list of screen names, up to 100 in total.
1102
-     */
1103
-    public function usersLookup($userIds = null, $screenNames = null)
1104
-    {
1105
-        // redefine
1106
-        $userIds     = (array)$userIds;
1107
-        $screenNames = (array)$screenNames;
1108
-
1109
-        // validate
1110
-        if (empty($userIds) && empty($screenNames)) throw new TwitterException('Specify an userId or a screenName.');
1111
-
1112
-        // build parameters
1113
-        if (!empty($userIds)) $parameters['user_id'] = implode(',', $userIds);
1114
-        if (!empty($screenNames)) $parameters['screen_name'] = implode(',', $screenNames);
1115
-
1116
-        // make the call
1117
-        return (array)$this->doCall('users/lookup.json', $parameters, true);
1118
-
1119
-    }
1120
-
1121
-    /**
1122
-     * Run a search for users similar to the Find People button on Twitter.com; the same results returned by people search on Twitter.com will be returned by using this API.
1123
-     * Usage note: It is only possible to retrieve the first 1000 matches from this API.
1124
-     *
1125
-     * @return    array
1126
-     * @param    string $q  The search query term.
1127
-     * @param           int [optional] $perPage    Specifies the number of results to retrieve.
1128
-     * @param           int [optional] $page        Specifies the page of results to retrieve.
1129
-     */
1130
-    public function usersSearch($q, $perPage = null, $page = null)
1131
-    {
1132
-        // build parameters
1133
-        $parameters['q'] = (string)$q;
1134
-        if ($perPage != null) $parameters['per_page'] = (int)$perPage;
1135
-        if ($page != null) $parameters['page'] = (int)$page;
1136
-
1137
-        // make the call
1138
-        return (array)$this->doCall('users/search.json', $parameters, true);
1139
-
1140
-    }
1141
-
1142
-    /**
1143
-     * Access to Twitter's suggested user list. This returns the list of suggested user categories. The category can be used in the users/suggestions/category  endpoint to get the users in that category.
1144
-     *
1145
-     * @return    array
1146
-     */
1147
-    public function usersSuggestions()
1148
-    {
1149
-        return (array)$this->doCall('users/suggestions.json', null, true);
1150
-    }
1151
-
1152
-    /**
1153
-     * Access the users in a given category of the Twitter suggested user list.
1154
-     * It is recommended that end clients cache this data for no more than one hour.
1155
-     *
1156
-     * @return    array
1157
-     * @param    string $slug The short name of list or a category.
1158
-     */
1159
-    public function usersSuggestionsSlug($slug)
1160
-    {
1161
-        return (array)$this->doCall('users/suggestions/' . (string)$slug . '.json');
1162
-    }
1163
-
1164
-    /**
1165
-     * Returns a user's friends, each with current status inline. They are ordered by the order in which the user followed them, most recently followed first, 100 at a time.
1166
-     * (Please note that the result set isn't guaranteed to be 100 every time as suspended users will be filtered out.)
1167
-     *
1168
-     * Use the cursor option to access older friends.
1169
-     * With no user specified, request defaults to the authenticated user's friends.
1170
-     * It's also possible to request another user's friends list via the id, screen_name or user_id parameter.
1171
-     *
1172
-     * @return    array
1173
-     * @param    string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1174
-     * @param    string [optional] $userId        Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1175
-     * @param    string [optional] $screenName    Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1176
-     * @param    int    [optional] $cursor            Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1177
-     */
1178
-    public function statusesFriends($id = null, $userId = null, $screenName = null, $cursor = null)
1179
-    {
1180
-        // build parameters
1181
-        $parameters = array();
1182
-        if ($id != null) $parameters['id'] = (string)$id;
1183
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1184
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1185
-        if ($cursor != null) $parameters['cursor'] = (int)$cursor;
1186
-
1187
-        // make the call
1188
-        return (array)$this->doCall('statuses/friends.json', $parameters);
1189
-    }
1190
-
1191
-    /**
1192
-     * Returns the authenticating user's followers, each with current status inline. They are ordered by the order in which they followed the user, 100 at a time. (Please note that the result set isn't guaranteed to be 100 every time as suspended users will be filtered out.)
1193
-     * Use the cursor parameter to access earlier followers.
1194
-     *
1195
-     * @return    array
1196
-     * @param    string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1197
-     * @param    string [optional] $userId        Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1198
-     * @param    string [optional] $screenName    Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1199
-     * @param    int    [optional] $cursor            Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1200
-     */
1201
-    public function statusesFollowers($id = null, $userId = null, $screenName = null, $cursor = null)
1202
-    {
1203
-        // build parameters
1204
-        $parameters = array();
1205
-        if ($id != null) $parameters['id'] = (string)$id;
1206
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1207
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1208
-        if ($cursor != null) $parameters['cursor'] = (int)$cursor;
1209
-
1210
-        // make the call
1211
-        return (array)$this->doCall('statuses/followers.json', $parameters);
1212
-    }
1213
-
1214
-
1215
-    // Trends resources
1216
-    /**
1217
-     * Returns the top ten topics that are currently trending on Twitter.
1218
-     * The response includes the time of the request, the name of each trend, and the url to the Twitter Search results page for that topic.
1219
-     *
1220
-     * @return    array
1221
-     */
1222
-    public function trends()
1223
-    {
1224
-        return (array)$this->doCall('trends.json');
1225
-    }
1226
-
1227
-    /**
1228
-     * Returns the current top 10 trending topics on Twitter.
1229
-     * The response includes the time of the request, the name of each trending topic, and query used on Twitter Search results page for that topic.
1230
-     *
1231
-     * @return    array
1232
-     * @param    string [optional] $exclude    Setting this equal to hashtags will remove all hashtags from the trends list.
1233
-     */
1234
-    public function trendsCurrent($exclude = null)
1235
-    {
1236
-        // build parameters
1237
-        $parameters = array();
1238
-        if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1239
-
1240
-        // make the call
1241
-        return (array)$this->doCall('trends/current.json', $parameters);
1242
-    }
1243
-
1244
-    /**
1245
-     * Returns the top 20 trending topics for each hour in a given day.
1246
-     *
1247
-     * @return    array
1248
-     * @param    string [optional] $exclude    Setting this equal to hashtags will remove all hashtags from the trends list.
1249
-     * @param    string [optional] $date        Permits specifying a start date for the report. The date should be formatted YYYY-MM-DD.
1250
-     */
1251
-    public function trendsDaily($exclude = null, $date = null)
1252
-    {
1253
-        // build parameters
1254
-        $parameters = array();
1255
-        if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1256
-        if ($date != null) $parameters['date'] = (string)$date;
1257
-
1258
-        // make the call
1259
-        return (array)$this->doCall('trends/daily.json', $parameters);
1260
-    }
1261
-
1262
-    /**
1263
-     * Returns the top 30 trending topics for each day in a given week.
1264
-     *
1265
-     * @return    array
1266
-     * @param    string [optional] $exclude    Setting this equal to hashtags will remove all hashtags from the trends list.
1267
-     * @param    string [optional] $date        Permits specifying a start date for the report. The date should be formatted YYYY-MM-DD.
1268
-     */
1269
-    public function trendsWeekly($exclude = null, $date = null)
1270
-    {
1271
-        // build parameters
1272
-        $parameters = array();
1273
-        if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1274
-        if ($date != null) $parameters['date'] = (string)$date;
1275
-
1276
-        // make the call
1277
-        return (array)$this->doCall('trends/weekly.json', $parameters);
1278
-    }
1279
-
1280
-
1281
-    // List resources
1282
-    /**
1283
-     * Creates a new list for the authenticated user. Accounts are limited to 20 lists.
1284
-     *
1285
-     *
1286
-     * @param    string $user The user.
1287
-     * @param    string $name The name of the list you are creating.
1288
-     * @param null      $mode
1289
-     * @param null      $description
1290
-     * @return array
1291
-     * @throws TwitterException
1292
-     * @internal param $string [optional] $mode            Whether your list is public or private. Values can be public or private. Lists are public by default if no mode is specified.
1293
-     * @internal param $string [optional] $description    The description of the list you are creating.
1294
-     */
1295
-    public function userListsCreate($user, $name, $mode = null, $description = null)
1296
-    {
1297
-        // possible modes
1298
-        $allowedModes = array('public', 'private');
1299
-
1300
-        // validate
1301
-        if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.');
1302
-
1303
-        // build parameters
1304
-        $parameters['name'] = (string)$name;
1305
-        if ($mode != null) $parameters['mode'] = (string)$mode;
1306
-        if ($description != null) $parameters['description'] = (string)$description;
1307
-
1308
-        // make the call
1309
-        return (array)$this->doCall((string)$user . '/lists.json', $parameters, true, 'POST');
1310
-    }
1311
-
1312
-    /**
1313
-     * List the lists of the specified user. Private lists will be included if the authenticated users is the same as the user who's lists are being returned.
1314
-     *
1315
-     * @return    array
1316
-     * @param    string $user  The user.
1317
-     * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1318
-     */
1319
-    public function userLists($user, $cursor = null)
1320
-    {
1321
-        $parameters = null;
1322
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1323
-
1324
-        // make the call
1325
-        return (array)$this->doCall((string)$user . '/lists.json', $parameters, true);
1326
-    }
1327
-
1328
-    /**
1329
-     * Show the specified list. Private lists will only be shown if the authenticated user owns the specified list.
1330
-     *
1331
-     * @return    array
1332
-     * @param    string $user The user.
1333
-     * @param    string $id   The id of the list.
1334
-     */
1335
-    public function userListsId($user, $id)
1336
-    {
1337
-        // make the call
1338
-        return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '.json', null, true);
1339
-    }
1340
-
1341
-    /**
1342
-     * Updates the specified list.
1343
-     *
1344
-     *
1345
-     * @param    string $user The user.
1346
-     * @param    string $id   The id of the list.
1347
-     * @param null      $name
1348
-     * @param null      $mode
1349
-     * @param null      $description
1350
-     * @return array
1351
-     * @throws TwitterException
1352
-     * @internal param $string [optional] $name            The name of the list you are creating.
1353
-     * @internal param $string [optional] $mode            Whether your list is public or private. Values can be public or private. Lists are public by default if no mode is specified.
1354
-     * @internal param $string [optional] $description    The description of the list you are creating.
1355
-     */
1356
-    public function userListsIdUpdate($user, $id, $name = null, $mode = null, $description = null)
1357
-    {
1358
-        // possible modes
1359
-        $allowedModes = array('public', 'private');
1360
-
1361
-        // validate
1362
-        if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.');
1363
-
1364
-        // build parameters
1365
-        if ($name != null) $parameters['name'] = (string)$name;
1366
-        if ($mode != null) $parameters['mode'] = (string)$mode;
1367
-        if ($description != null) $parameters['description'] = (string)$description;
1368
-
1369
-        // make the call
1370
-        return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '.json', $parameters, true, 'POST');
1371
-    }
1372
-
1373
-    /**
1374
-     * Show tweet timeline for members of the specified list.
1375
-     *
1376
-     *
1377
-     * @param    string $user The user.
1378
-     * @param    string $id   The id of the list.
1379
-     * @param null      $sinceId
1380
-     * @param null      $maxId
1381
-     * @param null      $count
1382
-     * @param null      $page
1383
-     * @return array
1384
-     * @throws TwitterException
1385
-     * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
1386
-     * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
1387
-     * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
1388
-     * @internal param $int [optional] $page            Specifies the page of results to retrieve.
1389
-     */
1390
-    public function userListsIdStatuses($user, $id, $sinceId = null, $maxId = null, $count = null, $page = null)
1391
-    {
1392
-        // validate
1393
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1394
-
1395
-        // build parameters
1396
-        $parameters = array();
1397
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1398
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1399
-        if ($count != null) $parameters['per_page'] = (int)$count;
1400
-        if ($page != null) $parameters['page'] = (int)$page;
1401
-
1402
-        // make the call
1403
-        return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '/statuses.json', $parameters);
1404
-    }
1405
-
1406
-    /**
1407
-     * List the lists the specified user has been added to.
1408
-     *
1409
-     * @return    array
1410
-     * @param    string $user  The user.
1411
-     * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1412
-     */
1413
-    public function userListsMemberships($user, $cursor = null)
1414
-    {
1415
-        $parameters = null;
1416
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1417
-
1418
-        // make the call
1419
-        return (array)$this->doCall((string)$user . '/lists/memberships.json', $parameters, true);
1420
-    }
1421
-
1422
-    /**
1423
-     * List the lists the specified user follows.
1424
-     *
1425
-     * @return    array
1426
-     * @param    string $user  The user.
1427
-     * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1428
-     */
1429
-    public function userListsSubscriptions($user, $cursor = null)
1430
-    {
1431
-        $parameters = null;
1432
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1433
-
1434
-        // make the call
1435
-        return (array)$this->doCall((string)$user . '/lists/subscriptions.json', $parameters, true);
1436
-    }
1437
-
1438
-
1439
-    // List Members resources
1440
-    /**
1441
-     * Returns the members of the specified list.
1442
-     *
1443
-     * @return    array
1444
-     * @param    string $user  The user.
1445
-     * @param    string $id    The id of the list.
1446
-     * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1447
-     */
1448
-    public function userListMembers($user, $id, $cursor = null)
1449
-    {
1450
-        $parameters = null;
1451
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1452
-
1453
-        // make the call
1454
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true);
1455
-    }
1456
-
1457
-    /**
1458
-     * Add a member to a list. The authenticated user must own the list to be able to add members to it. Lists are limited to having 500 members.
1459
-     *
1460
-     * @return    array
1461
-     * @param    string $user   The user.
1462
-     * @param    string $id     The id of the list.
1463
-     * @param    string $userId The id or screen name of the user to add as a member of the list.
1464
-     */
1465
-    public function userListMembersCreate($user, $id, $userId)
1466
-    {
1467
-        // build parameters
1468
-        $parameters['id'] = (string)$userId;
1469
-
1470
-        // make the call
1471
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true, 'POST');
1472
-    }
1473
-
1474
-    /**
1475
-     * Removes the specified member from the list. The authenticated user must be the list's owner to remove members from the list.
1476
-     *
1477
-     * @return    mixed
1478
-     * @param    string $user   The user.
1479
-     * @param    string $id     The id of the list.
1480
-     * @param    string $userId Specfies the ID of the user for whom to return results for.
1481
-     */
1482
-    public function userListMembersDelete($user, $id, $userId)
1483
-    {
1484
-        // build parameters
1485
-        $parameters['id']      = (string)$userId;
1486
-        $parameters['_method'] = 'DELETE';
1487
-
1488
-        // make the call
1489
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true, 'POST');
1490
-    }
1491
-
1492
-    /**
1493
-     * Check if a user is a member of the specified list.
1494
-     *
1495
-     *
1496
-     * @param    string $user   The user.
1497
-     * @param    string $id     The id of the list.
1498
-     * @param    string $userId Specfies the ID of the user for whom to return results for.
1499
-     * @return mixed
1500
-     * @throws TwitterException
1501
-     */
1502
-    public function userListMembersId($user, $id, $userId)
1503
-    {
1504
-        try {
1505
-            // make the call
1506
-            return (array)$this->doCall((string)$user . '/' . (string)$id . '/members/' . (string)$userId . '.json', null, true);
1507
-        } // catch exceptions
1508
-        catch (TwitterException $e) {
1509
-            if ($e->getMessage() === 'The specified user is not a member of this list') {
1510
-                return false;
1511
-            } else throw $e;
1512
-        }
1513
-    }
1514
-
1515
-
1516
-    // List Subscribers resources
1517
-    /**
1518
-     * Returns the subscribers of the specified list.
1519
-     *
1520
-     * @return    array
1521
-     * @param    string $user  The user.
1522
-     * @param    string $id    The id of the list.
1523
-     * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1524
-     */
1525
-    public function userListSubscribers($user, $id, $cursor = null)
1526
-    {
1527
-        $parameters = null;
1528
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1529
-
1530
-        // make the call
1531
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', $parameters, true);
1532
-    }
1533
-
1534
-    /**
1535
-     * Make the authenticated user follow the specified list.
1536
-     *
1537
-     * @return    array
1538
-     * @param    string $user The user.
1539
-     * @param    string $id   The id of the list.
1540
-     */
1541
-    public function userListSubscribersCreate($user, $id)
1542
-    {
1543
-        // make the call
1544
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', null, true, 'POST');
1545
-    }
1546
-
1547
-    /**
1548
-     * Unsubscribes the authenticated user form the specified list.
1549
-     *
1550
-     * @return    array
1551
-     * @param    string $user The user.
1552
-     * @param    string $id   The id of the list.
1553
-     */
1554
-    public function userListSubscribersDelete($user, $id)
1555
-    {
1556
-        // build parameters
1557
-        $parameters['_method'] = 'DELETE';
1558
-
1559
-        // make the call
1560
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', $parameters, true, 'POST');
1561
-    }
1562
-
1563
-    /**
1564
-     * Check if the specified user is a subscriber of the specified list.
1565
-     *
1566
-     *
1567
-     * @param    string $user   The user.
1568
-     * @param    string $id     The id of the list.
1569
-     * @param    string $userId Specfies the ID of the user for whom to return results for.
1570
-     * @return mixed
1571
-     * @throws TwitterException
1572
-     */
1573
-    public function userListSubscribersId($user, $id, $userId)
1574
-    {
1575
-        try {
1576
-            // make the call
1577
-            return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers/' . (string)$userId . '.json', null, true);
1578
-        } // catch exceptions
1579
-        catch (TwitterException $e) {
1580
-            if ($e->getMessage() === 'The specified user is not a subscriber of this list') {
1581
-                return false;
1582
-            } else throw $e;
1583
-        }
1584
-
1585
-    }
1586
-
1587
-
1588
-    // Direct Messages resources
1589
-    /**
1590
-     * Returns a list of the 20 most recent direct messages sent to the authenticating user.
1591
-     *
1592
-     *
1593
-     * @param null $sinceId
1594
-     * @param null $maxId
1595
-     * @param null $count
1596
-     * @param null $page
1597
-     * @return array
1598
-     * @throws TwitterException
1599
-     * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
1600
-     * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
1601
-     * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
1602
-     * @internal param $int [optional] $page            Specifies the page of results to retrieve.
1603
-     */
1604
-    public function directMessages($sinceId = null, $maxId = null, $count = null, $page = null)
1605
-    {
1606
-        // validate
1607
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1608
-
1609
-        // build parameters
1610
-        $parameters = array();
1611
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1612
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1613
-        if ($count != null) $parameters['count'] = (int)$count;
1614
-        if ($page != null) $parameters['page'] = (int)$page;
1615
-
1616
-        // make the call
1617
-        return (array)$this->doCall('direct_messages.json', $parameters, true);
1618
-    }
1619
-
1620
-    /**
1621
-     * Returns a list of the 20 most recent direct messages sent by the authenticating user.
1622
-     *
1623
-     *
1624
-     * @param null $sinceId
1625
-     * @param null $maxId
1626
-     * @param null $count
1627
-     * @param null $page
1628
-     * @return array
1629
-     * @throws TwitterException
1630
-     * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
1631
-     * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
1632
-     * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
1633
-     * @internal param $int [optional] $page            Specifies the page of results to retrieve.
1634
-     */
1635
-    public function directMessagesSent($sinceId = null, $maxId = null, $count = null, $page = null)
1636
-    {
1637
-        // validate
1638
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1639
-
1640
-        // build parameters
1641
-        $parameters = array();
1642
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1643
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1644
-        if ($count != null) $parameters['count'] = (int)$count;
1645
-        if ($page != null) $parameters['page'] = (int)$page;
1646
-
1647
-        // make the call
1648
-        return (array)$this->doCall('direct_messages/sent.json', $parameters, true);
1649
-    }
1650
-
1651
-    /**
1652
-     * Sends a new direct message to the specified user from the authenticating user.
1653
-     * Requires both the user and text parameters. Returns the sent message in the requested format when successful.
1654
-     *
1655
-     *
1656
-     * @param    string $text The text of your direct message. Be sure to URL encode as necessary, and keep it under 140 characters.
1657
-     * @param null      $id
1658
-     * @param null      $userId
1659
-     * @param null      $screenName
1660
-     * @return array
1661
-     * @throws TwitterException
1662
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1663
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1664
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1665
-     */
1666
-    public function directMessagesNew($text, $id = null, $userId = null, $screenName = null)
1667
-    {
1668
-        // validate
1669
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1670
-
1671
-        // build parameters
1672
-        $parameters['text'] = (string)$text;
1673
-        if ($id != null) $parameters['user'] = (string)$id;
1674
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1675
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1676
-
1677
-        // make the call
1678
-        return (array)$this->doCall('direct_messages/new.json', $parameters, true, 'POST');
1679
-    }
1680
-
1681
-    /**
1682
-     * Destroys the direct message specified in the required ID parameter. The authenticating user must be the recipient of the specified direct message.
1683
-     *
1684
-     * @return    array
1685
-     * @param    string $id The ID of the desired direct message.
1686
-     */
1687
-    public function directMessagesDestroy($id)
1688
-    {
1689
-        // build parameters
1690
-        $parameters['id'] = (string)$id;
1691
-
1692
-        // make the call
1693
-        return (array)$this->doCall('direct_messages/destroy.json', $parameters, true, 'POST');
1694
-    }
1695
-
1696
-
1697
-    // Friendship resources
1698
-    /**
1699
-     * Allows the authenticating users to follow the user specified in the ID parameter.
1700
-     * Returns the befriended user in the requested format when successful.
1701
-     * Returns a string describing the failure condition when unsuccessful.
1702
-     *
1703
-     *
1704
-     * @param null $id
1705
-     * @param null $userId
1706
-     * @param null $screenName
1707
-     * @param bool $follow
1708
-     * @return mixed
1709
-     * @throws TwitterException
1710
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1711
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1712
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1713
-     * @internal param $bool [optional] $follow            Returns public statuses that reference the given set of users.
1714
-     */
1715
-    public function friendshipsCreate($id = null, $userId = null, $screenName = null, $follow = false)
1716
-    {
1717
-        // validate
1718
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1719
-
1720
-        // build parameters
1721
-        if ($id != null) $parameters['id'] = (string)$id;
1722
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1723
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1724
-        $parameters['follow'] = $follow ? 'true' : 'false';
1725
-
1726
-        // make the call
1727
-        return (array)$this->doCall('friendships/create.json', $parameters, true, 'POST');
1728
-    }
1729
-
1730
-    /**
1731
-     * Allows the authenticating users to unfollow the user specified in the ID parameter.
1732
-     * Returns the unfollowed user in the requested format when successful. Returns a string describing the failure condition when unsuccessful.
1733
-     *
1734
-     *
1735
-     * @param null $id
1736
-     * @param null $userId
1737
-     * @param null $screenName
1738
-     * @return array
1739
-     * @throws TwitterException
1740
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1741
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1742
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1743
-     */
1744
-    public function friendshipsDestroy($id = null, $userId = null, $screenName = null)
1745
-    {
1746
-        // validate
1747
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1748
-
1749
-        // build parameters
1750
-        if ($id != null) $parameters['id'] = (string)$id;
1751
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1752
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1753
-
1754
-        // make the call
1755
-        return (array)$this->doCall('friendships/destroy.json', $parameters, true, 'POST');
1756
-    }
1757
-
1758
-    /**
1759
-     * Tests for the existence of friendship between two users. Will return true if user_a follows user_b, otherwise will return false.
1760
-     *
1761
-     * @return    bool
1762
-     * @param    string $userA The ID or screen_name of the subject user.
1763
-     * @param    string $userB The ID or screen_name of the user to test for following.
1764
-     */
1765
-    public function friendshipsExists($userA, $userB)
1766
-    {
1767
-        // build parameters
1768
-        $parameters['user_a'] = (string)$userA;
1769
-        $parameters['user_b'] = (string)$userB;
1770
-
1771
-        // make the call
1772
-        return (bool)$this->doCall('friendships/exists.json', $parameters);
1773
-    }
1774
-
1775
-    /**
1776
-     * Returns detailed information about the relationship between two users.
1777
-     *
1778
-     *
1779
-     * @param null $sourceId
1780
-     * @param null $sourceScreenName
1781
-     * @param null $targetId
1782
-     * @param null $targetScreenName
1783
-     * @return array
1784
-     * @throws TwitterException
1785
-     * @internal param $string [optional] $sourceId                The user_id of the subject user.
1786
-     * @internal param $string [optional] $sourceScreenName        The screen_name of the subject user.
1787
-     * @internal param $string [optional] $targetId                The screen_name of the subject user.
1788
-     * @internal param $string [optional] $targetScreenName        The screen_name of the target user.
1789
-     */
1790
-    public function friendshipsShow($sourceId = null, $sourceScreenName = null, $targetId = null, $targetScreenName = null)
1791
-    {
1792
-        // validate
1793
-        if ($sourceId == '' && $sourceScreenName == '') throw new TwitterException('Specify an sourceId or a sourceScreenName.');
1794
-        if ($targetId == '' && $targetScreenName == '') throw new TwitterException('Specify an targetId or a targetScreenName.');
1795
-
1796
-        // build parameters
1797
-        if ($sourceId != null) $parameters['source_id'] = (string)$sourceId;
1798
-        if ($sourceScreenName != null) $parameters['source_screen_name'] = (string)$sourceScreenName;
1799
-        if ($targetId != null) $parameters['target_id'] = (string)$targetId;
1800
-        if ($targetScreenName != null) $parameters['target_screen_name'] = (string)$targetScreenName;
1801
-
1802
-        // make the call
1803
-        return (array)$this->doCall('friendships/show.json', $parameters);
1804
-    }
1805
-
1806
-    /**
1807
-     * Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user.
1808
-     *
1809
-     * @return    array
1810
-     * @param    string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1811
-     */
1812
-    public function friendshipsIncoming($cursor = null)
1813
-    {
1814
-        $parameters = null;
1815
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1816
-
1817
-        // make the call
1818
-        return (array)$this->doCall('friendships/incoming.json', $parameters, true);
1819
-    }
1820
-
1821
-    /**
1822
-     * Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request.
1823
-     *
1824
-     * @return    array
1825
-     * @param    string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1826
-     */
1827
-    public function friendshipsOutgoing($cursor = null)
1828
-    {
1829
-        $parameters = null;
1830
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1831
-
1832
-        // make the call
1833
-        return (array)$this->doCall('friendships/outgoing.json', $parameters, true);
1834
-    }
1835
-
1836
-
1837
-    // Friends and Followers resources
1838
-    /**
1839
-     * Returns an array of numeric IDs for every user the specified user is following.
1840
-     *
1841
-     *
1842
-     * @param null $id
1843
-     * @param null $userId
1844
-     * @param null $screenName
1845
-     * @param null $cursor
1846
-     * @return array
1847
-     * @throws TwitterException
1848
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1849
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1850
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1851
-     * @internal param $string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1852
-     */
1853
-    public function friendsIds($id = null, $userId = null, $screenName = null, $cursor = null)
1854
-    {
1855
-        // validate
1856
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1857
-
1858
-        // build parameters
1859
-        if ($id != null) $parameters['id'] = (string)$id;
1860
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1861
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1862
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1863
-
1864
-        // make the call
1865
-        return (array)$this->doCall('friends/ids.json', $parameters);
1866
-    }
1867
-
1868
-    /**
1869
-     * Returns an array of numeric IDs for every user following the specified user.
1870
-     *
1871
-     *
1872
-     * @param null $id
1873
-     * @param null $userId
1874
-     * @param null $screenName
1875
-     * @param null $cursor
1876
-     * @return array
1877
-     * @throws TwitterException
1878
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1879
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1880
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1881
-     * @internal param $string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1882
-     */
1883
-    public function followersIds($id = null, $userId = null, $screenName = null, $cursor = null)
1884
-    {
1885
-        // validate
1886
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1887
-
1888
-        // build parameters
1889
-        if ($id != null) $parameters['id'] = (string)$id;
1890
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1891
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1892
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1893
-
1894
-        // make the call
1895
-        return (array)$this->doCall('followers/ids.json', $parameters);
1896
-    }
1897
-
1898
-
1899
-    // Account resources
1900
-    /**
1901
-     * Returns an HTTP 200 OK response code and a representation of the requesting user if authentication was successful; returns a 401 status code and an error message if not. Use this method to test if supplied user credentials are valid.
1902
-     *
1903
-     * @return    array
1904
-     */
1905
-    public function accountVerifyCredentials()
1906
-    {
1907
-        // make the call
1908
-        return (array)$this->doCall('account/verify_credentials.json', null, true);
1909
-    }
1910
-
1911
-    /**
1912
-     *
1913
-     * @return    array
1914
-     */
1915
-    public function accountRateLimitStatus()
1916
-    {
1917
-        // make the call
1918
-        return (array)$this->doCall('account/rate_limit_status.json', null);
1919
-    }
1920
-
1921
-    /**
1922
-     * Ends the session of the authenticating user, returning a null cookie. Use this method to sign users out of client-facing applications like widgets.
1923
-     * @return bool
1924
-     * @throws TwitterException
1925
-     */
1926
-    public function accountEndSession()
1927
-    {
1928
-        try {
1929
-            // make the call
1930
-            $this->doCall('account/end_session.json', null, true, 'POST');
1931
-        } // catch exceptions
1932
-        catch (TwitterException $e) {
1933
-            if ($e->getMessage() === 'Logged out.') {
1934
-                return true;
1935
-            } else throw $e;
1936
-        }
1937
-    }
1938
-
1939
-    /**
1940
-     * Sets which device Twitter delivers updates to for the authenticating user. Sending none as the device parameter will disable IM or SMS updates.
1941
-     *
1942
-     * @return    array
1943
-     * @param    string $device Delivery device type to send updates to.
1944
-     */
1945
-    public function accountUpdateDeliveryDevices($device)
1946
-    {
1947
-        // build parameters
1948
-        $parameters['device'] = (string)$device;
1949
-
1950
-        // make the call
1951
-        return (array)$this->doCall('account/update_delivery_device.json', $parameters, true, 'POST');
1952
-    }
1953
-
1954
-    /**
1955
-     * Sets one or more hex values that control the color scheme of the authenticating user's profile page on twitter.com.
1956
-     * Each parameter's value must be a valid hexidecimal value, and may be either three or six characters (ex: #fff or #ffffff).
1957
-     *
1958
-     *
1959
-     * @param null $profileBackgroundColor
1960
-     * @param null $profileTextColor
1961
-     * @param null $profileLinkColor
1962
-     * @param null $profileSidebarFillColor
1963
-     * @param null $profileSidebarBorderColor
1964
-     * @return array
1965
-     * @throws TwitterException
1966
-     * @internal param $string [optional] $profileBackgroundColor        Profile background color.
1967
-     * @internal param $string [optional] $profileTextColor                Profile text color.
1968
-     * @internal param $string [optional] $profileLinkColor                Profile link color.
1969
-     * @internal param $string [optional] $profileSidebarFillColor        Profile sidebar's background color.
1970
-     * @internal param $string [optional] $profileSidebarBorderColor        Profile sidebar's border color.
1971
-     */
1972
-    public function accountUpdateProfileColors($profileBackgroundColor = null, $profileTextColor = null, $profileLinkColor = null, $profileSidebarFillColor = null, $profileSidebarBorderColor = null)
1973
-    {
1974
-        // validate
1975
-        if ($profileBackgroundColor == '' && $profileTextColor == '' && $profileLinkColor == '' && $profileSidebarFillColor == ''
1976
-            && $profileSidebarBorderColor == ''
1977
-        ) throw new TwitterException('Specify a profileBackgroundColor, profileTextColor, profileLinkColor, profileSidebarFillColor or a profileSidebarBorderColor.');
1978
-
1979
-        // build parameters
1980
-        if ($profileBackgroundColor != null) $parameters['profile_background_color'] = (string)$profileBackgroundColor;
1981
-        if ($profileTextColor != null) $parameters['profile_text_color'] = (string)$profileTextColor;
1982
-        if ($profileLinkColor != null) $parameters['profile_link_color'] = (string)$profileLinkColor;
1983
-        if ($profileSidebarFillColor != null) $parameters['profile_sidebar_fill_color'] = (string)$profileSidebarFillColor;
1984
-        if ($profileSidebarBorderColor != null) $parameters['profile_sidebar_border_color'] = (string)$profileSidebarBorderColor;
1985
-
1986
-        // make the call
1987
-        return (array)$this->doCall('account/update_profile_colors.json', $parameters, true, 'POST');
1988
-    }
1989
-
1990
-    /**
1991
-     * Updates the authenticating user's profile image.
1992
-     *
1993
-     *
1994
-     * @param    string $image The path to the avatar image for the profile. Must be a valid GIF, JPG, or PNG image of less than 700 kilobytes in size. Images with width larger than 500 pixels will be scaled down.
1995
-     * @return array
1996
-     * @throws TwitterException
1997
-     */
1998
-    public function accountUpdateProfileImage($image)
1999
-    {
2000
-        throw new TwitterException('Not implemented');
2001
-
2002
-        // validate
2003
-        if (!file_exists($image)) throw new TwitterException('Image (' . $image . ') doesn\'t exists.');
2004
-
2005
-        // make the call
2006
-        return (array)$this->doCall('account/update_profile_image.json', null, true, 'POST', $image);
2007
-    }
2008
-
2009
-    /**
2010
-     * Updates the authenticating user's profile background image.
2011
-     *
2012
-     *
2013
-     * @param    string $image The path to the background image for the profile. Must be a valid GIF, JPG, or PNG image of less than 800 kilobytes in size. Images with width larger than 2048 pixels will be forceably scaled down.
2014
-     * @param    bool   $tile  Whether or not to tile the background image. If set to true the background image will be displayed tiled. The image will not be tiled otherwise.
2015
-     * @return array
2016
-     * @throws TwitterException
2017
-     */
2018
-    public function accountUpdateProfileBackgroundImage($image, $tile = false)
2019
-    {
2020
-        throw new TwitterException('Not implemented');
2021
-
2022
-        // validate
2023
-        if (!file_exists($image)) throw new TwitterException('Image (' . $image . ') doesn\'t exists.');
2024
-
2025
-        // build parameters
2026
-        if ($tile) $parameters['tile'] = 'true';
2027
-
2028
-        // make the call
2029
-        return (array)$this->doCall('account/update_profile_background_image.json', $parameters, true, 'POST', $image);
2030
-    }
2031
-
2032
-    /**
2033
-     * Sets values that users are able to set under the "Account" tab of their settings page. Only the parameters specified will be updated.
2034
-     *
2035
-     * @return    array
2036
-     * @param    string [optional] $name            Full name associated with the profile. Maximum of 20 characters.
2037
-     * @param    string [optional] $url            URL associated with the profile. Will be prepended with "http://" if not present. Maximum of 100 characters.
2038
-     * @param    string [optional] $location        The city or country describing where the user of the account is located. The contents are not normalized or geocoded in any way. Maximum of 30 characters.
2039
-     * @param    string [optional] $description    A description of the user owning the account. Maximum of 160 characters.
2040
-     */
2041
-    public function accountUpdateProfile($name = null, $url = null, $location = null, $description = null)
2042
-    {
2043
-        // build parameters
2044
-        $parameters = null;
2045
-        if ($name != null) $parameters['name'] = (string)$name;
2046
-        if ($url != null) $parameters['url'] = (string)$url;
2047
-        if ($location != null) $parameters['location'] = (string)$location;
2048
-        if ($description != null) $parameters['description'] = (string)$description;
2049
-
2050
-        // make the call
2051
-        return (array)$this->doCall('account/update_profile.json', $parameters, true, 'POST');
2052
-    }
2053
-
2054
-
2055
-    // Favorites resources
2056
-    /**
2057
-     * Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter in the requested format.
2058
-     *
2059
-     * @return    array
2060
-     * @param    string [optional] $id    Specifies the ID or screen name of the user for whom to return results for.
2061
-     * @param    int    [optional] $page        Specifies the page of results to retrieve.
2062
-     */
2063
-    public function favorites($id = null, $page = null)
2064
-    {
2065
-        // build parameters
2066
-        $parameters = null;
2067
-        if ($id != null) $parameters['id'] = (string)$id;
2068
-        if ($page != null) $parameters['page'] = (int)$page;
2069
-
2070
-        // make the call
2071
-        return (array)$this->doCall('favorites.json', $parameters, true);
2072
-    }
2073
-
2074
-    /**
2075
-     * Favorites the status specified in the ID parameter as the authenticating user. Returns the favorite status when successful.
2076
-     *
2077
-     * @return    array
2078
-     * @param    string $id The numerical ID of the desired status.
2079
-     */
2080
-    public function favoritesCreate($id)
2081
-    {
2082
-        // make the call
2083
-        return (array)$this->doCall('favorites/create/' . $id . '.json', null, true, 'POST');
2084
-    }
2085
-
2086
-    /**
2087
-     * Un-favorites the status specified in the ID parameter as the authenticating user. Returns the un-favorited status in the requested format when successful.
2088
-     *
2089
-     * @return    array
2090
-     * @param    string $id The numerical ID of the desired status.
2091
-     */
2092
-    public function favoritesDestroy($id)
2093
-    {
2094
-        // make the call
2095
-        return (array)$this->doCall('favorites/destroy/' . $id . '.json', null, true, 'POST');
2096
-    }
2097
-
2098
-
2099
-    // Notification resources
2100
-    /**
2101
-     * Enables device notifications for updates from the specified user. Returns the specified user when successful.
2102
-     *
2103
-     *
2104
-     * @param null $id
2105
-     * @param null $userId
2106
-     * @param null $screenName
2107
-     * @return array
2108
-     * @throws TwitterException
2109
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2110
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2111
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2112
-     */
2113
-    public function notificationsFollow($id = null, $userId = null, $screenName = null)
2114
-    {
2115
-        // validate
2116
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2117
-
2118
-        // build parameters
2119
-        if ($id != null) $parameters['id'] = (string)$id;
2120
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2121
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2122
-
2123
-        // make the call
2124
-        return (array)$this->doCall('notifications/follow.json', $parameters, true, 'POST');
2125
-    }
2126
-
2127
-    /**
2128
-     * Disables notifications for updates from the specified user to the authenticating user. Returns the specified user when successful.
2129
-     *
2130
-     *
2131
-     * @param null $id
2132
-     * @param null $userId
2133
-     * @param null $screenName
2134
-     * @return array
2135
-     * @throws TwitterException
2136
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2137
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2138
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2139
-     */
2140
-    public function notificationsLeave($id = null, $userId = null, $screenName = null)
2141
-    {
2142
-        // validate
2143
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2144
-
2145
-        // build parameters
2146
-        if ($id != null) $parameters['id'] = (string)$id;
2147
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2148
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2149
-
2150
-        // make the call
2151
-        return (array)$this->doCall('notifications/leave.json', $parameters, true, 'POST');
2152
-    }
2153
-
2154
-
2155
-    // Block resources
2156
-    /**
2157
-     * Blocks the user specified in the ID parameter as the authenticating user. Destroys a friendship to the blocked user if it exists. Returns the blocked user in the requested format when successful.
2158
-     *
2159
-     *
2160
-     * @param null $id
2161
-     * @param null $userId
2162
-     * @param null $screenName
2163
-     * @return array
2164
-     * @throws TwitterException
2165
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2166
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2167
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2168
-     */
2169
-    public function blocksCreate($id = null, $userId = null, $screenName = null)
2170
-    {
2171
-        // validate
2172
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2173
-
2174
-        // build parameters
2175
-        if ($id != null) $parameters['id'] = (string)$id;
2176
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2177
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2178
-
2179
-        // make the call
2180
-        return (array)$this->doCall('blocks/create.json', $parameters, true, 'POST');
2181
-    }
2182
-
2183
-    /**
2184
-     * Un-blocks the user specified in the ID parameter for the authenticating user. Returns the un-blocked user in the requested format when successful.
2185
-     *
2186
-     *
2187
-     * @param null $id
2188
-     * @param null $userId
2189
-     * @param null $screenName
2190
-     * @return array
2191
-     * @throws TwitterException
2192
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2193
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2194
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2195
-     */
2196
-    public function blocksDestroy($id = null, $userId = null, $screenName = null)
2197
-    {
2198
-        // validate
2199
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2200
-
2201
-        // build parameters
2202
-        if ($id != null) $parameters['id'] = (string)$id;
2203
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2204
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2205
-
2206
-        // make the call
2207
-        return (array)$this->doCall('blocks/destroy.json', $parameters, true, 'POST');
2208
-    }
2209
-
2210
-    /**
2211
-     * Un-blocks the user specified in the ID parameter for the authenticating user. Returns the un-blocked user in the requested format when successful.
2212
-     *
2213
-     *
2214
-     * @param null $id
2215
-     * @param null $userId
2216
-     * @param null $screenName
2217
-     * @return mixed
2218
-     * @throws TwitterException
2219
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2220
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2221
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2222
-     */
2223
-    public function blocksExists($id = null, $userId = null, $screenName = null)
2224
-    {
2225
-        // validate
2226
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2227
-
2228
-        // build parameters
2229
-        if ($id != null) $parameters['id'] = (string)$id;
2230
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2231
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2232
-
2233
-        try {
2234
-            // make the call
2235
-            return (array)$this->doCall('blocks/exists.json', $parameters, true);
2236
-        } // catch exceptions
2237
-        catch (TwitterException $e) {
2238
-            if ($e->getMessage() === 'You are not blocking this user.') {
2239
-                return false;
2240
-            } else throw $e;
2241
-        }
2242
-    }
2243
-
2244
-    /**
2245
-     * Returns an array of user objects that the authenticating user is blocking.
2246
-     *
2247
-     * @return    array
2248
-     * @param    int [optional] $page        Specifies the page of results to retrieve. Note: there are pagination limits. See the FAQ for details.
2249
-     */
2250
-    public function blocksBlocking($page = null)
2251
-    {
2252
-        // build parameters
2253
-        $parameters = null;
2254
-        if ($page != null) $parameters['page'] = (int)$page;
2255
-
2256
-        // make the call
2257
-        return (array)$this->doCall('blocks/blocking.json', $parameters, true);
2258
-    }
2259
-
2260
-    /**
2261
-     * Returns an array of numeric user ids the authenticating user is blocking.
2262
-     *
2263
-     * @return    array
2264
-     */
2265
-    public function blocksBlockingIds()
2266
-    {
2267
-        // make the call
2268
-        return (array)$this->doCall('blocks/blocking/ids.json', null, true);
2269
-    }
2270
-
2271
-
2272
-    // Spam Reporting resources
2273
-    /**
2274
-     * The user specified in the id is blocked by the authenticated user and reported as a spammer.
2275
-     *
2276
-     *
2277
-     * @param null $id
2278
-     * @param null $userId
2279
-     * @param null $screenName
2280
-     * @return array
2281
-     * @throws TwitterException
2282
-     * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2283
-     * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2284
-     * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2285
-     */
2286
-    public function reportSpam($id = null, $userId = null, $screenName = null)
2287
-    {
2288
-        // validate
2289
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2290
-
2291
-        // build parameters
2292
-        if ($id != null) $parameters['id'] = (string)$id;
2293
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2294
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2295
-
2296
-        // make the call
2297
-        return (array)$this->doCall('report_spam.json', $parameters, true, 'POST');
2298
-    }
2299
-
2300
-
2301
-    // Saved Searches resources
2302
-    /**
2303
-     * Returns the authenticated user's saved search queries.
2304
-     *
2305
-     * @return    array
2306
-     */
2307
-    public function savedSearches()
2308
-    {
2309
-        // make the call
2310
-        return (array)$this->doCall('saved_searches.json', null, true);
2311
-    }
2312
-
2313
-    /**
2314
-     * Retrieve the data for a saved search owned by the authenticating user specified by the given id.
2315
-     *
2316
-     * @return    array
2317
-     * @param    string $id The ID of the desired saved search.
2318
-     */
2319
-    public function savedSearchesShow($id)
2320
-    {
2321
-        // build parameters
2322
-        $parameters['id'] = (string)$id;
2323
-
2324
-        // make the call
2325
-        return (array)$this->doCall('saved_searches/show.json', $parameters, true);
2326
-    }
2327
-
2328
-    /**
2329
-     * Creates a saved search for the authenticated user.
2330
-     *
2331
-     * @return    array
2332
-     * @param    string $query The query of the search the user would like to save.
2333
-     */
2334
-    public function savedSearchesCreate($query)
2335
-    {
2336
-        // build parameters
2337
-        $parameters['query'] = (string)$query;
2338
-
2339
-        // make the call
2340
-        return (array)$this->doCall('saved_searches/create.json', $parameters, true, 'POST');
2341
-    }
2342
-
2343
-    /**
2344
-     * Destroys a saved search for the authenticated user. The search specified by id must be owned by the authenticating user.
2345
-     * REMARK: This method seems not to work    @later
2346
-     *
2347
-     * @return    array
2348
-     * @param    string $id The ID of the desired saved search.
2349
-     */
2350
-    public function savedSearchesDestroy($id)
2351
-    {
2352
-        return (array)$this->doCall('saved_searches/destroy/' . (string)$id . '.json', null, true, 'POST');
2353
-    }
2354
-
2355
-
2356
-    // OAuth resources
2357
-    /**
2358
-     * Allows a Consumer application to obtain an OAuth Request Token to request user authorization.
2359
-     * This method fulfills Secion 6.1 of the OAuth 1.0 authentication flow.
2360
-     *
2361
-     *
2362
-     * @param    string $callbackURL
2363
-     * @return array An array containg the token and the secret
2364
-     * @throws TwitterException
2365
-     */
2366
-    public function oAuthRequestToken($callbackURL = null)
2367
-    {
2368
-        // init var
2369
-        $parameters = array();
2370
-
2371
-        // set callback
2372
-        if ($callbackURL != null) $parameters['oauth_callback'] = (string)$callbackURL;
2373
-
2374
-        // make the call
2375
-        $response = $this->doOAuthCall('request_token', $parameters);
2376
-
2377
-        // validate
2378
-        if (!isset($response['oauth_token'], $response['oauth_token_secret'])) throw new TwitterException(implode(', ', array_keys($response)));
2379
-
2380
-        // set some properties
2381
-        if (isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']);
2382
-        if (isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']);
2383
-
2384
-        // return
2385
-        return $response;
2386
-    }
2387
-
2388
-    /**
2389
-     * Allows a Consumer application to exchange the OAuth Request Token for an OAuth Access Token.
2390
-     * This method fulfills Secion 6.3 of the OAuth 1.0 authentication flow.
2391
-     *
2392
-     * @return    array
2393
-     * @param    string $token
2394
-     * @param    string $verifier
2395
-     */
2396
-    public function oAuthAccessToken($token, $verifier)
2397
-    {
2398
-        // init var
2399
-        $parameters                   = array();
2400
-        $parameters['oauth_token']    = (string)$token;
2401
-        $parameters['oauth_verifier'] = (string)$verifier;
2402
-
2403
-        // make the call
2404
-        $response = $this->doOAuthCall('access_token', $parameters);
2405
-
2406
-        // set some properties
2407
-        if (isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']);
2408
-        if (isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']);
2409
-
2410
-        // return
2411
-        return $response;
2412
-    }
2413
-
2414
-    /**
2415
-     * Will redirect to the page to authorize the applicatione
2416
-     *
2417
-     * @return    void
2418
-     */
2419
-    public function oAuthAuthorize()
2420
-    {
2421
-        header('Location: ' . self::SECURE_API_URL . '/oauth/authorize?oauth_token=' . $this->oAuthToken);
2422
-    }
2423
-
2424
-    /**
2425
-     * Allows a Consumer application to use an OAuth request_token to request user authorization. This method is a replacement fulfills Secion 6.2 of the OAuth 1.0 authentication flow for applications using the Sign in with Twitter authentication flow. The method will use the currently logged in user as the account to for access authorization unless the force_login parameter is set to true
2426
-     * REMARK: This method seems not to work    @later
2427
-     *
2428
-     * @return    void
2429
-     */
2430
-    public function oAuthAuthenticate()
2431
-    {
2432
-        // make the call
2433
-        return $this->doOAuthCall('authenticate');
2434
-    }
2435
-
2436
-
2437
-    // Local Trends resources
2438
-    /**
2439
-     * Returns the locations that Twitter has trending topic information for.
2440
-     * The response is an array of "locations" that encode the location's WOEID (a Yahoo! Where On Earth ID) and some other human-readable information such as a canonical name and country the location belongs in.
2441
-     * The WOEID that is returned in the location object is to be used when querying for a specific trend.
2442
-     *
2443
-     * @return    array
2444
-     * @param    float [optional] $lat    If passed in conjunction with long, then the available trend locations will be sorted by distance to the lat  and long passed in. The sort is nearest to furthest.
2445
-     * @param    float [optional] $long    If passed in conjunction with lat, then the available trend locations will be sorted by distance to the lat  and long passed in. The sort is nearest to furthest.
2446
-     */
2447
-    public function trendsAvailable($lat = null, $long = null)
2448
-    {
2449
-        // build parameters
2450
-        $parameters = null;
2451
-        if ($lat != null) $parameters['lat_for_trends'] = (float)$lat;
2452
-        if ($long != null) $parameters['long_for_trends'] = (float)$long;
2453
-
2454
-        // make the call
2455
-        return (array)$this->doCall('trends/available.json', $parameters);
2456
-    }
2457
-
2458
-    /**
2459
-     * Returns the top 10 trending topics for a specific location Twitter has trending topic information for.
2460
-     * The response is an array of "trend" objects that encode the name of the trending topic, the query parameter that can be used to search for the topic on Search, and the direct URL that can be issued against Search.
2461
-     * This information is cached for five minutes, and therefore users are discouraged from querying these endpoints faster than once every five minutes. Global trends information is also available from this API by using a WOEID of 1.
2462
-     * REMARK: This method seems not to work    @later
2463
-     *
2464
-     * @return    array
2465
-     * @param    string $woeid The WOEID of the location to be querying for.
2466
-     */
2467
-    public function trendsLocation($woeid)
2468
-    {
2469
-        // make the call
2470
-        return (array)$this->doCall('trends/location/' . (string)$woeid . '.json');
2471
-    }
2472
-
2473
-
2474
-    // Geo resources
2475
-    /**
2476
-     * Search for places (cities and neighborhoods) that can be attached to a statuses/update. Given a latitude and a longitude, return a list of all the valid places that can be used as a place_id when updating a status.
2477
-     * Conceptually, a query can be made from the user's location, retrieve a list of places, have the user validate the location he or she is at, and then send the ID of this location up with a call to statuses/update.
2478
-     * There are multiple granularities of places that can be returned -- "neighborhoods", "cities", etc. At this time, only United States data is available through this method.
2479
-     * This API call is meant to be an informative call and will deliver generalized results about geography.
2480
-     *
2481
-     * @return    array
2482
-     * @param    float $lat   The location's latitude that this tweet refers to.
2483
-     * @param    float $long  The location's longitude that this tweet refers to.
2484
-     * @param          string [optional] $accuracy        A hint on the "region" in which to search. If a number, then this is a radius in meters, but it can also take a string that is suffixed with ft to specify feet. If this is not passed in, then it is assumed to be 0m. If coming from a device, in practice, this value is whatever accuracy the device has measuring its location (whether it be coming from a GPS, WiFi triangulation, etc.).
2485
-     * @param          string [optional] $granularity    The minimal granularity of data to return. If this is not passed in, then neighborhood is assumed. city can also be passed.
2486
-     * @param          int    [optional] $maxResults        A hint as to the number of results to return. This does not guarantee that the number of results returned will equal max_results, but instead informs how many "nearby" results to return. Ideally, only pass in the number of places you intend to display to the user here.
2487
-     */
2488
-    public function geoReverseGeoCode($lat, $long, $accuracy = null, $granularity = null, $maxResults = null)
2489
-    {
2490
-        // build parameters
2491
-        $parameters['lat']  = (float)$lat;
2492
-        $parameters['long'] = (float)$long;
2493
-        if ($accuracy != null) $parameters['accuracy'] = (string)$accuracy;
2494
-        if ($granularity != null) $parameters['granularity'] = (string)$granularity;
2495
-        if ($maxResults != null) $parameters['max_results'] = (int)$maxResults;
2496
-
2497
-        // make the call
2498
-        return (array)$this->doCall('geo/reverse_geocode.json', $parameters);
2499
-    }
2500
-
2501
-    /**
2502
-     * Find out more details of a place that was returned from the geo/reverse_geocode method.
2503
-     *
2504
-     * @return    array
2505
-     * @param    string $id
2506
-     * @param           string [optional] $placeId    A place in the world. These IDs can be retrieved from geo/reverse_geocode.
2507
-     */
2508
-    public function geoId($id, $placeId = null)
2509
-    {
2510
-        // build parameters
2511
-        $parameters = null;
2512
-        if ($placeId != null) $parameters['place_id'] = (string)$placeId;
2513
-
2514
-        // make the call
2515
-        return (array)$this->doCall('geo/id/' . (string)$id . '.json', $parameters);
2516
-    }
2517
-
2518
-
2519
-    // Help resources
2520
-    /**
2521
-     * Test
2522
-     * REMARK: this methods seems not to work, so don't rely on it
2523
-     *
2524
-     * @return    bool
2525
-     */
2526
-    public function helpTest()
2527
-    {
2528
-        // make the call
2529
-        return ($this->doCall('help/test', null, null, 'GET', null, false) == 'ok');
2530
-    }
44
+	// internal constant to enable/disable debugging
45
+	const DEBUG = false;
46
+
47
+	// url for the twitter-api
48
+	const API_URL        = 'https://api.twitter.com/1';
49
+	const SECURE_API_URL = 'https://api.twitter.com';
50
+
51
+	// port for the twitter-api
52
+	const API_PORT        = 443;
53
+	const SECURE_API_PORT = 443;
54
+
55
+	// current version
56
+	const VERSION = '2.0.1';
57
+
58
+	/**
59
+	 * A cURL instance
60
+	 *
61
+	 * @var    resource
62
+	 */
63
+	private $curl;
64
+
65
+	/**
66
+	 * The consumer key
67
+	 *
68
+	 * @var    string
69
+	 */
70
+	private $consumerKey;
71
+
72
+	/**
73
+	 * The consumer secret
74
+	 *
75
+	 * @var    string
76
+	 */
77
+	private $consumerSecret;
78
+
79
+	/**
80
+	 * The oAuth-token
81
+	 *
82
+	 * @var    string
83
+	 */
84
+	private $oAuthToken = '';
85
+
86
+	/**
87
+	 * The oAuth-token-secret
88
+	 *
89
+	 * @var    string
90
+	 */
91
+	private $oAuthTokenSecret = '';
92
+
93
+	/**
94
+	 * The timeout
95
+	 *
96
+	 * @var    int
97
+	 */
98
+	private $timeOut = 60;
99
+
100
+	/**
101
+	 * The user agent
102
+	 *
103
+	 * @var    string
104
+	 */
105
+	private $userAgent;
106
+
107
+	// class methods
108
+	/**
109
+	 * Default constructor
110
+	 *
111
+	 *
112
+	 * @param    string $consumerKey    The consumer key to use.
113
+	 * @param    string $consumerSecret The consumer secret to use.
114
+	 */
115
+	public function __construct($consumerKey, $consumerSecret)
116
+	{
117
+		$this->setConsumerKey($consumerKey);
118
+		$this->setConsumerSecret($consumerSecret);
119
+	}
120
+
121
+	/**
122
+	 * Default destructor
123
+	 *
124
+	 * @return    void
125
+	 */
126
+	public function __destruct()
127
+	{
128
+		if ($this->curl != null) curl_close($this->curl);
129
+	}
130
+
131
+	/**
132
+	 * Format the parameters as a querystring
133
+	 *
134
+	 * @return    string
135
+	 * @param    array $parameters
136
+	 */
137
+	private function buildQuery(array $parameters)
138
+	{
139
+		// no parameters?
140
+		if (empty($parameters)) return '';
141
+
142
+		// encode the keys
143
+		$keys = self::urlencode_rfc3986(array_keys($parameters));
144
+
145
+		// encode the values
146
+		$values = self::urlencode_rfc3986(array_values($parameters));
147
+
148
+		// reset the parameters
149
+		$parameters = array_combine($keys, $values);
150
+
151
+		// sort parameters by key
152
+		uksort($parameters, 'strcmp');
153
+
154
+		// loop parameters
155
+		foreach ($parameters as $key => $value) {
156
+			// sort by value
157
+			if (is_array($value)) $parameters[$key] = natsort($value);
158
+		}
159
+
160
+		// process parameters
161
+		foreach ($parameters as $key => $value) $chunks[] = $key . '=' . str_replace('%25', '%', $value);
162
+
163
+		// return
164
+		return implode('&', $chunks);
165
+	}
166
+
167
+	/**
168
+	 * All OAuth 1.0 requests use the same basic algorithm for creating a signature base string and a signature.
169
+	 * The signature base string is composed of the HTTP method being used, followed by an ampersand ("&") and then the URL-encoded base URL being accessed,
170
+	 * complete with path (but not query parameters), followed by an ampersand ("&").
171
+	 * Then, you take all query parameters and POST body parameters (when the POST body is of the URL-encoded type, otherwise the POST body is ignored),
172
+	 * including the OAuth parameters necessary for negotiation with the request at hand, and sort them in lexicographical order by first parameter name and
173
+	 * then parameter value (for duplicate parameters), all the while ensuring that both the key and the value for each parameter are URL encoded in isolation.
174
+	 * Instead of using the equals ("=") sign to mark the key/value relationship, you use the URL-encoded form of "%3D". Each parameter is then joined by the
175
+	 * URL-escaped ampersand sign, "%26".
176
+	 *
177
+	 * @return    string
178
+	 * @param    string $url
179
+	 * @param    string $method
180
+	 * @param    array  $parameters
181
+	 */
182
+	private function calculateBaseString($url, $method, array $parameters)
183
+	{
184
+		// redefine
185
+		$url        = (string)$url;
186
+		$parameters = (array)$parameters;
187
+
188
+		// init var
189
+		$pairs  = array();
190
+		$chunks = array();
191
+
192
+		// sort parameters by key
193
+		uksort($parameters, 'strcmp');
194
+
195
+		// loop parameters
196
+		foreach ($parameters as $key => $value) {
197
+			// sort by value
198
+			if (is_array($value)) $parameters[$key] = natsort($value);
199
+		}
200
+
201
+		// process queries
202
+		foreach ($parameters as $key => $value) {
203
+			$chunks[] = self::urlencode_rfc3986($key) . '%3D' . self::urlencode_rfc3986($value);
204
+		}
205
+
206
+		// buils base
207
+		$base = $method . '&';
208
+		$base .= urlencode($url) . '&';
209
+		$base .= implode('%26', $chunks);
210
+
211
+		// return
212
+		return $base;
213
+	}
214
+
215
+	/**
216
+	 * Build the Authorization header
217
+	 * @later: fix me
218
+	 *
219
+	 *
220
+	 * @param    array $parameters
221
+	 * @param null     $url
222
+	 * @return string
223
+	 */
224
+	private function calculateHeader(array $parameters, $url = null)
225
+	{
226
+		// redefine
227
+		$url = (string)$url;
228
+
229
+		// divide into parts
230
+		$parts = parse_url($url);
231
+
232
+		// init var
233
+		$chunks = array();
234
+
235
+		// process queries
236
+		foreach ($parameters as $key => $value) $chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key) . '="' . self::urlencode_rfc3986($value) . '"');
237
+
238
+		// build return
239
+		$return = 'Authorization: OAuth realm="' . $parts['scheme'] . '://' . $parts['host'] . $parts['path'] . '", ';
240
+		$return .= implode(',', $chunks);
241
+
242
+		// prepend name and OAuth part
243
+		return $return;
244
+	}
245
+
246
+	/**
247
+	 * Make an call to the oAuth
248
+	 * @todo    refactor me
249
+	 *
250
+	 *
251
+	 * @param    string $method
252
+	 * @param array     $parameters [optional] $parameters
253
+	 * @return array
254
+	 * @throws TwitterException
255
+	 */
256
+	private function doOAuthCall($method, array $parameters = null)
257
+	{
258
+		// redefine
259
+		$method = (string)$method;
260
+
261
+		// append default parameters
262
+		$parameters['oauth_consumer_key']     = $this->getConsumerKey();
263
+		$parameters['oauth_nonce']            = md5(microtime() . rand());
264
+		$parameters['oauth_timestamp']        = time();
265
+		$parameters['oauth_signature_method'] = 'HMAC-SHA1';
266
+		$parameters['oauth_version']          = '1.0';
267
+
268
+		// calculate the base string
269
+		$base = $this->calculateBaseString(self::SECURE_API_URL . '/oauth/' . $method, 'POST', $parameters);
270
+
271
+		// add sign into the parameters
272
+		$parameters['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret() . '&' . $this->getOAuthTokenSecret(), $base);
273
+
274
+		// calculate header
275
+		$header = $this->calculateHeader($parameters, self::SECURE_API_URL . '/oauth/' . $method);
276
+
277
+		// set options
278
+		$options[CURLOPT_URL]            = self::SECURE_API_URL . '/oauth/' . $method;
279
+		$options[CURLOPT_PORT]           = self::SECURE_API_PORT;
280
+		$options[CURLOPT_USERAGENT]      = $this->getUserAgent();
281
+		$options[CURLOPT_FOLLOWLOCATION] = true;
282
+		$options[CURLOPT_RETURNTRANSFER] = true;
283
+		$options[CURLOPT_TIMEOUT]        = (int)$this->getTimeOut();
284
+		$options[CURLOPT_SSL_VERIFYPEER] = false;
285
+		$options[CURLOPT_SSL_VERIFYHOST] = false;
286
+		$options[CURLOPT_HTTPHEADER]     = array('Expect:');
287
+		$options[CURLOPT_POST]           = 1;
288
+		$options[CURLOPT_POSTFIELDS]     = $this->buildQuery($parameters);
289
+
290
+		// init
291
+		if ($this->curl == null) $this->curl = curl_init();
292
+
293
+		// set options
294
+		curl_setopt_array($this->curl, $options);
295
+
296
+		// execute
297
+		$response = curl_exec($this->curl);
298
+		$headers  = curl_getinfo($this->curl);
299
+
300
+		// fetch errors
301
+		$errorNumber  = curl_errno($this->curl);
302
+		$errorMessage = curl_error($this->curl);
303
+
304
+		// error?
305
+		if ($errorNumber != '') throw new TwitterException($errorMessage, $errorNumber);
306
+
307
+		// init var
308
+		$return = array();
309
+
310
+		// parse the string
311
+		parse_str($response, $return);
312
+
313
+		// return
314
+		return $return;
315
+	}
316
+
317
+	/**
318
+	 * Make the call
319
+	 *
320
+	 *
321
+	 * @param    string $url
322
+	 * @param array     $parameters
323
+	 * @param bool      $authenticate
324
+	 * @param string    $method
325
+	 * @param null      $filePath
326
+	 * @param bool      $expectJSON
327
+	 * @return string
328
+	 * @throws TwitterException
329
+	 * @internal param $array [optiona] $aParameters
330
+	 * @internal param $bool [optional] $authenticate
331
+	 * @internal param $bool [optional] $usePost
332
+	 */
333
+	private function doCall($url, array $parameters = null, $authenticate = false, $method = 'GET', $filePath = null, $expectJSON = true)
334
+	{
335
+		// allowed methods
336
+		$allowedMethods = array('GET', 'POST');
337
+
338
+		// redefine
339
+		$url          = (string)$url;
340
+		$parameters   = (array)$parameters;
341
+		$authenticate = (bool)$authenticate;
342
+		$method       = (string)$method;
343
+		$expectJSON   = (bool)$expectJSON;
344
+
345
+		// validate method
346
+		if (!in_array($method, $allowedMethods)) throw new TwitterException('Unknown method (' . $method . '). Allowed methods are: ' . implode(', ', $allowedMethods));
347
+
348
+		// append default parameters
349
+		$oauth['oauth_consumer_key']     = $this->getConsumerKey();
350
+		$oauth['oauth_nonce']            = md5(microtime() . rand());
351
+		$oauth['oauth_timestamp']        = time();
352
+		$oauth['oauth_token']            = $this->getOAuthToken();
353
+		$oauth['oauth_signature_method'] = 'HMAC-SHA1';
354
+		$oauth['oauth_version']          = '1.0';
355
+
356
+		// set data
357
+		$data = $oauth;
358
+		if (!empty($parameters)) $data = array_merge($data, $parameters);
359
+
360
+		// calculate the base string
361
+		$base = $this->calculateBaseString(self::API_URL . '/' . $url, $method, $data);
362
+
363
+		// add sign into the parameters
364
+		$oauth['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret() . '&' . $this->getOAuthTokenSecret(), $base);
365
+
366
+		$headers[] = $this->calculateHeader($oauth, self::API_URL . '/' . $url);
367
+		$headers[] = 'Expect:';
368
+
369
+		// based on the method, we should handle the parameters in a different way
370
+		if ($method === 'POST') {
371
+			// file provided?
372
+			if ($filePath != null) {
373
+				// build a boundary
374
+				$boundary = md5(time());
375
+
376
+				// process file
377
+				$fileInfo = pathinfo($filePath);
378
+
379
+				// set mimeType
380
+				$mimeType = 'application/octet-stream';
381
+				if ($fileInfo['extension'] === 'jpg' || $fileInfo['extension'] === 'jpeg') {
382
+					$mimeType = 'image/jpeg';
383
+				} elseif ($fileInfo['extension'] === 'gif') $mimeType = 'image/gif';
384
+				elseif ($fileInfo['extension'] === 'png') $mimeType = 'image/png';
385
+
386
+				// init var
387
+				$content = '--' . $boundary . "\r\n";
388
+
389
+				// set file
390
+				$content = 'Content-Disposition: form-data; name="image";filename="' . $fileInfo['basename'] . '"' . "\r\n" . 'Content-Type: ' . $mimeType . "\r\n\r\n" . file_get_contents($filePath) . "\r\n--" . $boundary . "\r\n";
391
+
392
+				// build headers
393
+				$headers[] = 'Content-Type: multipart/form-data; boundary=' . $boundary;
394
+				$headers[] = 'Content-Length: ' . strlen($content);
395
+
396
+				// set content
397
+				$options[CURLOPT_POSTFIELDS] = $content;
398
+			} // no file
399
+			else $options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters);
400
+
401
+			// enable post
402
+			$options[CURLOPT_POST] = 1;
403
+		} else {
404
+			// add the parameters into the querystring
405
+			if (!empty($parameters)) $url .= '?' . $this->buildQuery($parameters);
406
+		}
407
+
408
+		// set options
409
+		$options[CURLOPT_URL]            = self::API_URL . '/' . $url;
410
+		$options[CURLOPT_PORT]           = self::API_PORT;
411
+		$options[CURLOPT_USERAGENT]      = $this->getUserAgent();
412
+		$options[CURLOPT_FOLLOWLOCATION] = true;
413
+		$options[CURLOPT_RETURNTRANSFER] = true;
414
+		$options[CURLOPT_TIMEOUT]        = (int)$this->getTimeOut();
415
+		$options[CURLOPT_SSL_VERIFYPEER] = false;
416
+		$options[CURLOPT_SSL_VERIFYHOST] = false;
417
+		$options[CURLOPT_HTTP_VERSION]   = CURL_HTTP_VERSION_1_1;
418
+		$options[CURLOPT_HTTPHEADER]     = $headers;
419
+
420
+		// init
421
+		if ($this->curl == null) $this->curl = curl_init();
422
+
423
+		// set options
424
+		curl_setopt_array($this->curl, $options);
425
+
426
+		// execute
427
+		$response = curl_exec($this->curl);
428
+		$headers  = curl_getinfo($this->curl);
429
+
430
+		// fetch errors
431
+		$errorNumber  = curl_errno($this->curl);
432
+		$errorMessage = curl_error($this->curl);
433
+
434
+		// we don't expext JSON, return the response
435
+		if (!$expectJSON) return $response;
436
+
437
+		// replace ids with their string values, added because of some PHP-version can't handle these large values
438
+		$response = preg_replace('/id":(\d+)/', 'id":"\1"', $response);
439
+
440
+		// we expect JSON, so decode it
441
+		$json = @json_decode($response, true);
442
+
443
+		// validate JSON
444
+		if ($json === null) {
445
+			// should we provide debug information
446
+			if (self::DEBUG) {
447
+				// make it output proper
448
+				echo '<pre>';
449
+
450
+				// dump the header-information
451
+				var_dump($headers);
452
+
453
+				// dump the error
454
+				var_dump($errorMessage);
455
+
456
+				// dump the raw response
457
+				var_dump($response);
458
+
459
+				// end proper format
460
+				echo '</pre>';
461
+			}
462
+
463
+			// throw exception
464
+			throw new TwitterException('Invalid response.');
465
+		}
466
+
467
+		// any errors
468
+		if (isset($json['errors'])) {
469
+			// should we provide debug information
470
+			if (self::DEBUG) {
471
+				// make it output proper
472
+				echo '<pre>';
473
+
474
+				// dump the header-information
475
+				var_dump($headers);
476
+
477
+				// dump the error
478
+				var_dump($errorMessage);
479
+
480
+				// dump the raw response
481
+				var_dump($response);
482
+
483
+				// end proper format
484
+				echo '</pre>';
485
+			}
486
+
487
+			// throw exception
488
+			if (isset($json['errors'][0]['message'])) {
489
+				throw new TwitterException($json['errors'][0]['message']);
490
+			} else throw new TwitterException('Invalid response.');
491
+		}
492
+
493
+		// any error
494
+		if (isset($json['error'])) {
495
+			// should we provide debug information
496
+			if (self::DEBUG) {
497
+				// make it output proper
498
+				echo '<pre>';
499
+
500
+				// dump the header-information
501
+				var_dump($headers);
502
+
503
+				// dump the raw response
504
+				var_dump($response);
505
+
506
+				// end proper format
507
+				echo '</pre>';
508
+			}
509
+
510
+			// throw exception
511
+			throw new TwitterException($json['error']);
512
+		}
513
+
514
+		// return
515
+		return $json;
516
+	}
517
+
518
+	/**
519
+	 * Get the consumer key
520
+	 *
521
+	 * @return    string
522
+	 */
523
+	private function getConsumerKey()
524
+	{
525
+		return $this->consumerKey;
526
+	}
527
+
528
+	/**
529
+	 * Get the consumer secret
530
+	 *
531
+	 * @return    string
532
+	 */
533
+	private function getConsumerSecret()
534
+	{
535
+		return $this->consumerSecret;
536
+	}
537
+
538
+	/**
539
+	 * Get the oAuth-token
540
+	 *
541
+	 * @return    string
542
+	 */
543
+	private function getOAuthToken()
544
+	{
545
+		return $this->oAuthToken;
546
+	}
547
+
548
+	/**
549
+	 * Get the oAuth-token-secret
550
+	 *
551
+	 * @return    string
552
+	 */
553
+	private function getOAuthTokenSecret()
554
+	{
555
+		return $this->oAuthTokenSecret;
556
+	}
557
+
558
+	/**
559
+	 * Get the timeout
560
+	 *
561
+	 * @return    int
562
+	 */
563
+	public function getTimeOut()
564
+	{
565
+		return (int)$this->timeOut;
566
+	}
567
+
568
+	/**
569
+	 * Get the useragent that will be used. Our version will be prepended to yours.
570
+	 * It will look like: "PHP Twitter/<version> <your-user-agent>"
571
+	 *
572
+	 * @return    string
573
+	 */
574
+	public function getUserAgent()
575
+	{
576
+		return (string)'PHP Twitter/' . self::VERSION . ' ' . $this->userAgent;
577
+	}
578
+
579
+	/**
580
+	 * Set the consumer key
581
+	 *
582
+	 * @return    void
583
+	 * @param    string $key The consumer key to use.
584
+	 */
585
+	private function setConsumerKey($key)
586
+	{
587
+		$this->consumerKey = (string)$key;
588
+	}
589
+
590
+	/**
591
+	 * Set the consumer secret
592
+	 *
593
+	 * @return    void
594
+	 * @param    string $secret The consumer secret to use.
595
+	 */
596
+	private function setConsumerSecret($secret)
597
+	{
598
+		$this->consumerSecret = (string)$secret;
599
+	}
600
+
601
+	/**
602
+	 * Set the oAuth-token
603
+	 *
604
+	 * @return    void
605
+	 * @param    string $token The token to use.
606
+	 */
607
+	public function setOAuthToken($token)
608
+	{
609
+		$this->oAuthToken = (string)$token;
610
+	}
611
+
612
+	/**
613
+	 * Set the oAuth-secret
614
+	 *
615
+	 * @return    void
616
+	 * @param    string $secret The secret to use.
617
+	 */
618
+	public function setOAuthTokenSecret($secret)
619
+	{
620
+		$this->oAuthTokenSecret = (string)$secret;
621
+	}
622
+
623
+	/**
624
+	 * Set the timeout
625
+	 *
626
+	 * @return    void
627
+	 * @param    int $seconds The timeout in seconds
628
+	 */
629
+	public function setTimeOut($seconds)
630
+	{
631
+		$this->timeOut = (int)$seconds;
632
+	}
633
+
634
+	/**
635
+	 * Get the useragent that will be used. Our version will be prepended to yours.
636
+	 * It will look like: "PHP Twitter/<version> <your-user-agent>"
637
+	 *
638
+	 * @return    void
639
+	 * @param    string $userAgent Your user-agent, it should look like <app-name>/<app-version>
640
+	 */
641
+	public function setUserAgent($userAgent)
642
+	{
643
+		$this->userAgent = (string)$userAgent;
644
+	}
645
+
646
+	/**
647
+	 * Build the signature for the data
648
+	 *
649
+	 * @return    string
650
+	 * @param    string $key  The key to use for signing.
651
+	 * @param    string $data The data that has to be signed.
652
+	 */
653
+	private function hmacsha1($key, $data)
654
+	{
655
+		return base64_encode(hash_hmac('SHA1', $data, $key, true));
656
+	}
657
+
658
+	/**
659
+	 * URL-encode method for internatl use
660
+	 *
661
+	 * @return    string
662
+	 * @param    mixed $value The value to encode.
663
+	 */
664
+	private static function urlencode_rfc3986($value)
665
+	{
666
+		if (is_array($value)) {
667
+			return array_map(array('Twitter', 'urlencode_rfc3986'), $value);
668
+		} else {
669
+			$search  = array('+', ' ', '%7E', '%');
670
+			$replace = array('%20', '%20', '~', '%25');
671
+
672
+			return str_replace($search, $replace, urlencode($value));
673
+		}
674
+	}
675
+
676
+
677
+	// Timeline resources
678
+	/**
679
+	 * Returns the 20 most recent statuses from non-protected users who have set a custom user icon.
680
+	 * The public timeline is cached for 60 seconds and requesting it more often than that is unproductive and a waste of resources.
681
+	 *
682
+	 * @return    array
683
+	 * @param    bool [optional] $skipUser    When true each tweet returned in a timeline will not contain an entire user object. Instead, the user node will contain only an id element to indicate the numerical ID of the Twitter user that set the status.
684
+	 */
685
+	public function statusesPublicTimeline($skipUser = false)
686
+	{
687
+		// redefine
688
+		$skipUser = (bool)$skipUser;
689
+
690
+		// build parameters
691
+		$parameters = array();
692
+		if ($skipUser) $parameters['skip_user'] = 'true';
693
+
694
+		// make the call
695
+		return (array)$this->doCall('statuses/public_timeline.json', $parameters);
696
+	}
697
+
698
+	/**
699
+	 * Returns the 20 most recent statuses posted by the authenticating user and that user's friends. This is the equivalent of /timeline/home on the Web.
700
+	 *
701
+	 * @return    array
702
+	 * @param    string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
703
+	 * @param    string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
704
+	 * @param    int    [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
705
+	 * @param    int    [optional] $page            Specifies the page of results to retrieve.
706
+	 * @param    bool   [optional] $skipUser    When true each tweet returned in a timeline will not contain an entire user object. Instead, the user node will contain only an id element to indicate the numerical ID of the Twitter user that set the status.
707
+	 */
708
+	public function statusesHomeTimeline($sinceId = null, $maxId = null, $count = null, $page = null, $skipUser = false)
709
+	{
710
+		// redefine
711
+		$skipUser = (bool)$skipUser;
712
+
713
+		// build parameters
714
+		$parameters = array();
715
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
716
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
717
+		if ($count != null) $parameters['count'] = (int)$count;
718
+		if ($page != null) $parameters['page'] = (int)$page;
719
+		if ($skipUser) $parameters['skip_user'] = 'true';
720
+
721
+		// make the call
722
+		return (array)$this->doCall('statuses/home_timeline.json', $parameters, true);
723
+	}
724
+
725
+	/**
726
+	 * Returns the 20 most recent statuses, including retweets, posted by the authenticating user and that user's friends.
727
+	 * This is the equivalent of /timeline/home on the Web.
728
+	 *
729
+	 * Usage note: This home_timeline call is identical to statuses/friends_timeline, except that home_timeline also contains retweets, while statuses/friends_timeline does not for backwards compatibility reasons.
730
+	 * In a future version of the API, statuses/friends_timeline will be deprected and replaced by home_timeline.
731
+	 *
732
+	 * @return    array
733
+	 * @param    string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
734
+	 * @param    string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
735
+	 * @param    int    [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
736
+	 * @param    int    [optional] $page            Specifies the page of results to retrieve.
737
+	 * @param    bool   [optional] $skipUser    When true each tweet returned in a timeline will not contain an entire user object. Instead, the user node will contain only an id element to indicate the numerical ID of the Twitter user that set the status.
738
+	 */
739
+	public function statusesFriendsTimeline($sinceId = null, $maxId = null, $count = null, $page = null, $skipUser = false)
740
+	{
741
+		// redefine
742
+		$skipUser = (bool)$skipUser;
743
+
744
+		// build parameters
745
+		$parameters = array();
746
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
747
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
748
+		if ($count != null) $parameters['count'] = (int)$count;
749
+		if ($page != null) $parameters['page'] = (int)$page;
750
+		if ($skipUser) $parameters['skip_user'] = 'true';
751
+
752
+		// make the call
753
+		return (array)$this->doCall('statuses/friends_timeline.json', $parameters, true);
754
+	}
755
+
756
+	/**
757
+	 * Returns the 20 most recent statuses posted from the authenticating user. It's also possible to request another user's timeline via the id parameter.
758
+	 * This is the equivalent of the Web / page for your own user, or the profile page for a third party.
759
+	 *
760
+	 * For backwards compatibility reasons, retweets are stripped out of the user_timeline when calling in XML or JSON (they appear with 'RT' in RSS and Atom).
761
+	 * If you'd like them included, you can merge them in from statuses retweeted_by_me.
762
+	 *
763
+	 * @return    array
764
+	 * @param    string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
765
+	 * @param    string [optional] $userId        Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
766
+	 * @param    string [optional] $screenName    Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
767
+	 * @param    string [optional] $sinceId        Returns results with an ID greater than (that is, more recent than) the specified ID.
768
+	 * @param    string [optional] $maxId            Returns results with an ID less than (that is, older than) or equal to the specified ID.
769
+	 * @param    int    [optional] $count            Specifies the number of records to retrieve. May not be greater than 200.
770
+	 * @param    int    [optional] $page                Specifies the page of results to retrieve.
771
+	 * @param    bool   [optional] $skipUser        When true each tweet returned in a timeline will not contain an entire user object. Instead, the user node will contain only an id element to indicate the numerical ID of the Twitter user that set the status.
772
+	 */
773
+	public function statusesUserTimeline($id = null, $userId = null, $screenName = null, $sinceId = null, $maxId = null, $count = null, $page = null, $skipUser = false)
774
+	{
775
+		// redefine
776
+		$skipUser = (bool)$skipUser;
777
+
778
+		// build parameters
779
+		$parameters = array();
780
+		if ($id != null) $parameters['id'] = (string)$id;
781
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
782
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
783
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
784
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
785
+		if ($count != null) $parameters['count'] = (int)$count;
786
+		if ($page != null) $parameters['page'] = (int)$page;
787
+		if ($skipUser) $parameters['skip_user'] = 'true';
788
+
789
+		// make the call
790
+		return (array)$this->doCall('statuses/user_timeline.json', $parameters, true);
791
+	}
792
+
793
+	/**
794
+	 * Returns the 20 most recent mentions (status containing @username) for the authenticating user.
795
+	 *
796
+	 *
797
+	 * @param null $sinceId
798
+	 * @param null $maxId
799
+	 * @param null $count
800
+	 * @param null $page
801
+	 * @return array
802
+	 * @throws TwitterException
803
+	 * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
804
+	 * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
805
+	 * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
806
+	 * @internal param $int [optional] $page            Specifies the page of results to retrieve.
807
+	 */
808
+	public function statusesMentions($sinceId = null, $maxId = null, $count = null, $page = null)
809
+	{
810
+		// validate
811
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
812
+
813
+		// build parameters
814
+		$parameters = array();
815
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
816
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
817
+		if ($count != null) $parameters['count'] = (int)$count;
818
+		if ($page != null) $parameters['page'] = (int)$page;
819
+
820
+		// make the call
821
+		return (array)$this->doCall('statuses/mentions.json', $parameters);
822
+	}
823
+
824
+	/**
825
+	 * Returns the 20 most recent retweets posted by the authenticating user.
826
+	 *
827
+	 *
828
+	 * @param null $sinceId
829
+	 * @param null $maxId
830
+	 * @param null $count
831
+	 * @param null $page
832
+	 * @return array
833
+	 * @throws TwitterException
834
+	 * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
835
+	 * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
836
+	 * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
837
+	 * @internal param $int [optional] $page            Specifies the page of results to retrieve.
838
+	 */
839
+	public function statusesRetweetedByMe($sinceId = null, $maxId = null, $count = null, $page = null)
840
+	{
841
+		// validate
842
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
843
+
844
+		// build parameters
845
+		$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;
850
+
851
+		// make the call
852
+		return (array)$this->doCall('statuses/retweeted_by_me.json', $parameters);
853
+	}
854
+
855
+	/**
856
+	 * Returns the 20 most recent retweets posted by the authenticating user's friends.
857
+	 *
858
+	 *
859
+	 * @param null $sinceId
860
+	 * @param null $maxId
861
+	 * @param null $count
862
+	 * @param null $page
863
+	 * @return array
864
+	 * @throws TwitterException
865
+	 * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
866
+	 * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
867
+	 * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
868
+	 * @internal param $int [optional] $page            Specifies the page of results to retrieve.
869
+	 */
870
+	public function statusesRetweetedToMe($sinceId = null, $maxId = null, $count = null, $page = null)
871
+	{
872
+		// validate
873
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
874
+
875
+		// build parameters
876
+		$parameters = array();
877
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
878
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
879
+		if ($count != null) $parameters['count'] = (int)$count;
880
+		if ($page != null) $parameters['page'] = (int)$page;
881
+
882
+		// make the call
883
+		return (array)$this->doCall('statuses/retweeted_by_me.json', $parameters);
884
+	}
885
+
886
+
887
+	// Tweets resources
888
+	/**
889
+	 * Returns the 20 most recent tweets of the authenticated user that have been retweeted by others.
890
+	 *
891
+	 *
892
+	 * @param null $sinceId
893
+	 * @param null $maxId
894
+	 * @param null $count
895
+	 * @param null $page
896
+	 * @return array
897
+	 * @throws TwitterException
898
+	 * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
899
+	 * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
900
+	 * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
901
+	 * @internal param $int [optional] $page            Specifies the page of results to retrieve.
902
+	 */
903
+	public function statusesReweetsOfMe($sinceId = null, $maxId = null, $count = null, $page = null)
904
+	{
905
+		// validate
906
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
907
+
908
+		// build parameters
909
+		$parameters = array();
910
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
911
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
912
+		if ($count != null) $parameters['count'] = (int)$count;
913
+		if ($page != null) $parameters['page'] = (int)$page;
914
+
915
+		// make the call
916
+		return (array)$this->doCall('statuses/retweets_of_me.json', $parameters);
917
+	}
918
+
919
+	/**
920
+	 * Returns a single status, specified by the id parameter below. The status's author will be returned inline.
921
+	 *
922
+	 * @return    array
923
+	 * @param    string $id The numerical ID of the desired status.
924
+	 */
925
+	public function statusesShow($id)
926
+	{
927
+		// build parameters
928
+		$parameters['id'] = (string)$id;
929
+
930
+		// make the call
931
+		return (array)$this->doCall('statuses/show.json', $parameters);
932
+	}
933
+
934
+	/**
935
+	 * Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
936
+	 *
937
+	 * @return    array
938
+	 * @param    string $status The text of your status update, up to 140 characters. URL encode as necessary.
939
+	 * @param           string  [optional] $inReplyToStatusId        The ID of an existing status that the update is in reply to.
940
+	 * @param           float   [optional] $lat                    The location's latitude that this tweet refers to.
941
+	 * @param           float   [optional] $long                    The location's longitude that this tweet refers to.
942
+	 * @param           string  [optional] $placeId                A place in the world. These IDs can be retrieved from geo/reverse_geocode.
943
+	 * @param           bool    [optional] $displayCoordinates        Whether or not to put a pin on the exact coordinates a tweet has been sent from.
944
+	 */
945
+	public function statusesUpdate($status, $inReplyToStatusId = null, $lat = null, $long = null, $placeId = null, $displayCoordinates = false)
946
+	{
947
+		// build parameters
948
+		$parameters['status'] = (string)$status;
949
+		if ($inReplyToStatusId != null) $parameters['in_reply_to_status_id'] = (string)$inReplyToStatusId;
950
+		if ($lat != null) $parameters['lat'] = (float)$lat;
951
+		if ($long != null) $parameters['long'] = (float)$long;
952
+		if ($placeId != null) $parameters['place_id'] = (string)$placeId;
953
+		if ($displayCoordinates) $parameters['display_coordinates'] = 'true';
954
+
955
+		// make the call
956
+		return (array)$this->doCall('statuses/update.json', $parameters, true, 'POST');
957
+	}
958
+
959
+	/**
960
+	 * Destroys the status specified by the required ID parameter.
961
+	 * Usage note: The authenticating user must be the author of the specified status.
962
+	 *
963
+	 * @return    bool
964
+	 * @param    string $id The numerical ID of the desired status.
965
+	 */
966
+	public function statusesDestroy($id)
967
+	{
968
+		// build parameters
969
+		$parameters['id'] = (string)$id;
970
+
971
+		// make the call
972
+		return (array)$this->doCall('statuses/destroy.json', $parameters, true, 'POST');
973
+	}
974
+
975
+	/**
976
+	 * Retweets a tweet. Returns the original tweet with retweet details embedded.
977
+	 *
978
+	 * @return    array
979
+	 * @param    string $id The numerical ID of the desired status.
980
+	 */
981
+	public function statusesRetweet($id)
982
+	{
983
+		// make the call
984
+		return (array)$this->doCall('statuses/retweet/' . $id . '.json', null, true, 'POST');
985
+	}
986
+
987
+	/**
988
+	 * Returns up to 100 of the first retweets of a given tweet.
989
+	 *
990
+	 *
991
+	 * @param    string $id The numerical ID of the desired status.
992
+	 * @param           int [optional] $count    Specifies the number of records to retrieve. May not be greater than 100.
993
+	 * @return array
994
+	 * @throws TwitterException
995
+	 */
996
+	public function statusesRetweets($id, $count = null)
997
+	{
998
+		// validate
999
+		if ($count != null && $count > 100) throw new TwitterException('Count may not be greater than 100.');
1000
+
1001
+		// build parameters
1002
+		$parameters = null;
1003
+		if ($count != null) $parameters['count'] = (int)$count;
1004
+
1005
+		// make the call
1006
+		return (array)$this->doCall('statuses/retweets/' . $id . '.json', $parameters);
1007
+	}
1008
+
1009
+	/**
1010
+	 * Show user objects of up to 100 members who retweeted the status.
1011
+	 *
1012
+	 *
1013
+	 * @param    string $id The numerical ID of the desired status.
1014
+	 * @param null      $count
1015
+	 * @param null      $page
1016
+	 * @return array
1017
+	 * @throws TwitterException
1018
+	 * @internal param $int [optional] $count    Specifies the number of records to retrieve. May not be greater than 200.
1019
+	 * @internal param $int [optional] $page        Specifies the page of results to retrieve.
1020
+	 */
1021
+	public function statusesIdRetweetedBy($id, $count = null, $page = null)
1022
+	{
1023
+		// validate
1024
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1025
+
1026
+		// build parameters
1027
+		$parameters = null;
1028
+		if ($count != null) $parameters['count'] = (int)$count;
1029
+		if ($page != null) $parameters['page'] = (int)$page;
1030
+
1031
+		// make the call
1032
+		return (array)$this->doCall('statuses/' . (string)$id . '/retweeted_by.json', $parameters, true);
1033
+	}
1034
+
1035
+	/**
1036
+	 * Show user ids of up to 100 users who retweeted the status.
1037
+	 *
1038
+	 *
1039
+	 * @param    string $id The numerical ID of the desired status.
1040
+	 * @param null      $count
1041
+	 * @param null      $page
1042
+	 * @return array
1043
+	 * @throws TwitterException
1044
+	 * @internal param $int [optional] $count    Specifies the number of records to retrieve. May not be greater than 200.
1045
+	 * @internal param $int [optional] $page        Specifies the page of results to retrieve.
1046
+	 */
1047
+	public function statusesIdRetweetedByIds($id, $count = null, $page = null)
1048
+	{
1049
+		// validate
1050
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1051
+
1052
+		// build parameters
1053
+		$parameters = null;
1054
+		if ($count != null) $parameters['count'] = (int)$count;
1055
+		if ($page != null) $parameters['page'] = (int)$page;
1056
+
1057
+		// make the call
1058
+		return (array)$this->doCall('statuses/' . (string)$id . '/retweeted_by/ids.json', $parameters, true);
1059
+	}
1060
+
1061
+
1062
+	// User resources
1063
+	/**
1064
+	 * Returns extended information of a given user, specified by ID or screen name as per the required id parameter.
1065
+	 * The author's most recent status will be returned inline.
1066
+	 *
1067
+	 *
1068
+	 * @param null $id
1069
+	 * @param null $userId
1070
+	 * @param null $screenName
1071
+	 * @return array
1072
+	 * @throws TwitterException
1073
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1074
+	 * @internal param $string [optional] $userId        Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1075
+	 * @internal param $string [optional] $screenName    Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1076
+	 */
1077
+	public function usersShow($id = null, $userId = null, $screenName = null)
1078
+	{
1079
+		// validate
1080
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1081
+
1082
+		// build parameters
1083
+		if ($id != null) $parameters['id'] = (string)$id;
1084
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
1085
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1086
+
1087
+		// make the call
1088
+		return (array)$this->doCall('users/show.json', $parameters);
1089
+	}
1090
+
1091
+	/**
1092
+	 * Return up to 100 users worth of extended information, specified by either ID, screen name, or combination of the two.
1093
+	 * The author's most recent status (if the authenticating user has permission) will be returned inline.
1094
+	 *
1095
+	 *
1096
+	 * @param null $userIds
1097
+	 * @param null $screenNames
1098
+	 * @return array
1099
+	 * @throws TwitterException
1100
+	 * @internal param $mixed [optional] $userIds        A comma separated list of user IDs, up to 100 in total.
1101
+	 * @internal param $mixed [optional] $screenNames    A comma separated list of screen names, up to 100 in total.
1102
+	 */
1103
+	public function usersLookup($userIds = null, $screenNames = null)
1104
+	{
1105
+		// redefine
1106
+		$userIds     = (array)$userIds;
1107
+		$screenNames = (array)$screenNames;
1108
+
1109
+		// validate
1110
+		if (empty($userIds) && empty($screenNames)) throw new TwitterException('Specify an userId or a screenName.');
1111
+
1112
+		// build parameters
1113
+		if (!empty($userIds)) $parameters['user_id'] = implode(',', $userIds);
1114
+		if (!empty($screenNames)) $parameters['screen_name'] = implode(',', $screenNames);
1115
+
1116
+		// make the call
1117
+		return (array)$this->doCall('users/lookup.json', $parameters, true);
1118
+
1119
+	}
1120
+
1121
+	/**
1122
+	 * Run a search for users similar to the Find People button on Twitter.com; the same results returned by people search on Twitter.com will be returned by using this API.
1123
+	 * Usage note: It is only possible to retrieve the first 1000 matches from this API.
1124
+	 *
1125
+	 * @return    array
1126
+	 * @param    string $q  The search query term.
1127
+	 * @param           int [optional] $perPage    Specifies the number of results to retrieve.
1128
+	 * @param           int [optional] $page        Specifies the page of results to retrieve.
1129
+	 */
1130
+	public function usersSearch($q, $perPage = null, $page = null)
1131
+	{
1132
+		// build parameters
1133
+		$parameters['q'] = (string)$q;
1134
+		if ($perPage != null) $parameters['per_page'] = (int)$perPage;
1135
+		if ($page != null) $parameters['page'] = (int)$page;
1136
+
1137
+		// make the call
1138
+		return (array)$this->doCall('users/search.json', $parameters, true);
1139
+
1140
+	}
1141
+
1142
+	/**
1143
+	 * Access to Twitter's suggested user list. This returns the list of suggested user categories. The category can be used in the users/suggestions/category  endpoint to get the users in that category.
1144
+	 *
1145
+	 * @return    array
1146
+	 */
1147
+	public function usersSuggestions()
1148
+	{
1149
+		return (array)$this->doCall('users/suggestions.json', null, true);
1150
+	}
1151
+
1152
+	/**
1153
+	 * Access the users in a given category of the Twitter suggested user list.
1154
+	 * It is recommended that end clients cache this data for no more than one hour.
1155
+	 *
1156
+	 * @return    array
1157
+	 * @param    string $slug The short name of list or a category.
1158
+	 */
1159
+	public function usersSuggestionsSlug($slug)
1160
+	{
1161
+		return (array)$this->doCall('users/suggestions/' . (string)$slug . '.json');
1162
+	}
1163
+
1164
+	/**
1165
+	 * Returns a user's friends, each with current status inline. They are ordered by the order in which the user followed them, most recently followed first, 100 at a time.
1166
+	 * (Please note that the result set isn't guaranteed to be 100 every time as suspended users will be filtered out.)
1167
+	 *
1168
+	 * Use the cursor option to access older friends.
1169
+	 * With no user specified, request defaults to the authenticated user's friends.
1170
+	 * It's also possible to request another user's friends list via the id, screen_name or user_id parameter.
1171
+	 *
1172
+	 * @return    array
1173
+	 * @param    string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1174
+	 * @param    string [optional] $userId        Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1175
+	 * @param    string [optional] $screenName    Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1176
+	 * @param    int    [optional] $cursor            Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1177
+	 */
1178
+	public function statusesFriends($id = null, $userId = null, $screenName = null, $cursor = null)
1179
+	{
1180
+		// build parameters
1181
+		$parameters = array();
1182
+		if ($id != null) $parameters['id'] = (string)$id;
1183
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
1184
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1185
+		if ($cursor != null) $parameters['cursor'] = (int)$cursor;
1186
+
1187
+		// make the call
1188
+		return (array)$this->doCall('statuses/friends.json', $parameters);
1189
+	}
1190
+
1191
+	/**
1192
+	 * Returns the authenticating user's followers, each with current status inline. They are ordered by the order in which they followed the user, 100 at a time. (Please note that the result set isn't guaranteed to be 100 every time as suspended users will be filtered out.)
1193
+	 * Use the cursor parameter to access earlier followers.
1194
+	 *
1195
+	 * @return    array
1196
+	 * @param    string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1197
+	 * @param    string [optional] $userId        Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1198
+	 * @param    string [optional] $screenName    Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1199
+	 * @param    int    [optional] $cursor            Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1200
+	 */
1201
+	public function statusesFollowers($id = null, $userId = null, $screenName = null, $cursor = null)
1202
+	{
1203
+		// build parameters
1204
+		$parameters = array();
1205
+		if ($id != null) $parameters['id'] = (string)$id;
1206
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
1207
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1208
+		if ($cursor != null) $parameters['cursor'] = (int)$cursor;
1209
+
1210
+		// make the call
1211
+		return (array)$this->doCall('statuses/followers.json', $parameters);
1212
+	}
1213
+
1214
+
1215
+	// Trends resources
1216
+	/**
1217
+	 * Returns the top ten topics that are currently trending on Twitter.
1218
+	 * The response includes the time of the request, the name of each trend, and the url to the Twitter Search results page for that topic.
1219
+	 *
1220
+	 * @return    array
1221
+	 */
1222
+	public function trends()
1223
+	{
1224
+		return (array)$this->doCall('trends.json');
1225
+	}
1226
+
1227
+	/**
1228
+	 * Returns the current top 10 trending topics on Twitter.
1229
+	 * The response includes the time of the request, the name of each trending topic, and query used on Twitter Search results page for that topic.
1230
+	 *
1231
+	 * @return    array
1232
+	 * @param    string [optional] $exclude    Setting this equal to hashtags will remove all hashtags from the trends list.
1233
+	 */
1234
+	public function trendsCurrent($exclude = null)
1235
+	{
1236
+		// build parameters
1237
+		$parameters = array();
1238
+		if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1239
+
1240
+		// make the call
1241
+		return (array)$this->doCall('trends/current.json', $parameters);
1242
+	}
1243
+
1244
+	/**
1245
+	 * Returns the top 20 trending topics for each hour in a given day.
1246
+	 *
1247
+	 * @return    array
1248
+	 * @param    string [optional] $exclude    Setting this equal to hashtags will remove all hashtags from the trends list.
1249
+	 * @param    string [optional] $date        Permits specifying a start date for the report. The date should be formatted YYYY-MM-DD.
1250
+	 */
1251
+	public function trendsDaily($exclude = null, $date = null)
1252
+	{
1253
+		// build parameters
1254
+		$parameters = array();
1255
+		if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1256
+		if ($date != null) $parameters['date'] = (string)$date;
1257
+
1258
+		// make the call
1259
+		return (array)$this->doCall('trends/daily.json', $parameters);
1260
+	}
1261
+
1262
+	/**
1263
+	 * Returns the top 30 trending topics for each day in a given week.
1264
+	 *
1265
+	 * @return    array
1266
+	 * @param    string [optional] $exclude    Setting this equal to hashtags will remove all hashtags from the trends list.
1267
+	 * @param    string [optional] $date        Permits specifying a start date for the report. The date should be formatted YYYY-MM-DD.
1268
+	 */
1269
+	public function trendsWeekly($exclude = null, $date = null)
1270
+	{
1271
+		// build parameters
1272
+		$parameters = array();
1273
+		if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1274
+		if ($date != null) $parameters['date'] = (string)$date;
1275
+
1276
+		// make the call
1277
+		return (array)$this->doCall('trends/weekly.json', $parameters);
1278
+	}
1279
+
1280
+
1281
+	// List resources
1282
+	/**
1283
+	 * Creates a new list for the authenticated user. Accounts are limited to 20 lists.
1284
+	 *
1285
+	 *
1286
+	 * @param    string $user The user.
1287
+	 * @param    string $name The name of the list you are creating.
1288
+	 * @param null      $mode
1289
+	 * @param null      $description
1290
+	 * @return array
1291
+	 * @throws TwitterException
1292
+	 * @internal param $string [optional] $mode            Whether your list is public or private. Values can be public or private. Lists are public by default if no mode is specified.
1293
+	 * @internal param $string [optional] $description    The description of the list you are creating.
1294
+	 */
1295
+	public function userListsCreate($user, $name, $mode = null, $description = null)
1296
+	{
1297
+		// possible modes
1298
+		$allowedModes = array('public', 'private');
1299
+
1300
+		// validate
1301
+		if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.');
1302
+
1303
+		// build parameters
1304
+		$parameters['name'] = (string)$name;
1305
+		if ($mode != null) $parameters['mode'] = (string)$mode;
1306
+		if ($description != null) $parameters['description'] = (string)$description;
1307
+
1308
+		// make the call
1309
+		return (array)$this->doCall((string)$user . '/lists.json', $parameters, true, 'POST');
1310
+	}
1311
+
1312
+	/**
1313
+	 * List the lists of the specified user. Private lists will be included if the authenticated users is the same as the user who's lists are being returned.
1314
+	 *
1315
+	 * @return    array
1316
+	 * @param    string $user  The user.
1317
+	 * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1318
+	 */
1319
+	public function userLists($user, $cursor = null)
1320
+	{
1321
+		$parameters = null;
1322
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1323
+
1324
+		// make the call
1325
+		return (array)$this->doCall((string)$user . '/lists.json', $parameters, true);
1326
+	}
1327
+
1328
+	/**
1329
+	 * Show the specified list. Private lists will only be shown if the authenticated user owns the specified list.
1330
+	 *
1331
+	 * @return    array
1332
+	 * @param    string $user The user.
1333
+	 * @param    string $id   The id of the list.
1334
+	 */
1335
+	public function userListsId($user, $id)
1336
+	{
1337
+		// make the call
1338
+		return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '.json', null, true);
1339
+	}
1340
+
1341
+	/**
1342
+	 * Updates the specified list.
1343
+	 *
1344
+	 *
1345
+	 * @param    string $user The user.
1346
+	 * @param    string $id   The id of the list.
1347
+	 * @param null      $name
1348
+	 * @param null      $mode
1349
+	 * @param null      $description
1350
+	 * @return array
1351
+	 * @throws TwitterException
1352
+	 * @internal param $string [optional] $name            The name of the list you are creating.
1353
+	 * @internal param $string [optional] $mode            Whether your list is public or private. Values can be public or private. Lists are public by default if no mode is specified.
1354
+	 * @internal param $string [optional] $description    The description of the list you are creating.
1355
+	 */
1356
+	public function userListsIdUpdate($user, $id, $name = null, $mode = null, $description = null)
1357
+	{
1358
+		// possible modes
1359
+		$allowedModes = array('public', 'private');
1360
+
1361
+		// validate
1362
+		if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.');
1363
+
1364
+		// build parameters
1365
+		if ($name != null) $parameters['name'] = (string)$name;
1366
+		if ($mode != null) $parameters['mode'] = (string)$mode;
1367
+		if ($description != null) $parameters['description'] = (string)$description;
1368
+
1369
+		// make the call
1370
+		return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '.json', $parameters, true, 'POST');
1371
+	}
1372
+
1373
+	/**
1374
+	 * Show tweet timeline for members of the specified list.
1375
+	 *
1376
+	 *
1377
+	 * @param    string $user The user.
1378
+	 * @param    string $id   The id of the list.
1379
+	 * @param null      $sinceId
1380
+	 * @param null      $maxId
1381
+	 * @param null      $count
1382
+	 * @param null      $page
1383
+	 * @return array
1384
+	 * @throws TwitterException
1385
+	 * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
1386
+	 * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
1387
+	 * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
1388
+	 * @internal param $int [optional] $page            Specifies the page of results to retrieve.
1389
+	 */
1390
+	public function userListsIdStatuses($user, $id, $sinceId = null, $maxId = null, $count = null, $page = null)
1391
+	{
1392
+		// validate
1393
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1394
+
1395
+		// build parameters
1396
+		$parameters = array();
1397
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1398
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1399
+		if ($count != null) $parameters['per_page'] = (int)$count;
1400
+		if ($page != null) $parameters['page'] = (int)$page;
1401
+
1402
+		// make the call
1403
+		return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '/statuses.json', $parameters);
1404
+	}
1405
+
1406
+	/**
1407
+	 * List the lists the specified user has been added to.
1408
+	 *
1409
+	 * @return    array
1410
+	 * @param    string $user  The user.
1411
+	 * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1412
+	 */
1413
+	public function userListsMemberships($user, $cursor = null)
1414
+	{
1415
+		$parameters = null;
1416
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1417
+
1418
+		// make the call
1419
+		return (array)$this->doCall((string)$user . '/lists/memberships.json', $parameters, true);
1420
+	}
1421
+
1422
+	/**
1423
+	 * List the lists the specified user follows.
1424
+	 *
1425
+	 * @return    array
1426
+	 * @param    string $user  The user.
1427
+	 * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1428
+	 */
1429
+	public function userListsSubscriptions($user, $cursor = null)
1430
+	{
1431
+		$parameters = null;
1432
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1433
+
1434
+		// make the call
1435
+		return (array)$this->doCall((string)$user . '/lists/subscriptions.json', $parameters, true);
1436
+	}
1437
+
1438
+
1439
+	// List Members resources
1440
+	/**
1441
+	 * Returns the members of the specified list.
1442
+	 *
1443
+	 * @return    array
1444
+	 * @param    string $user  The user.
1445
+	 * @param    string $id    The id of the list.
1446
+	 * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1447
+	 */
1448
+	public function userListMembers($user, $id, $cursor = null)
1449
+	{
1450
+		$parameters = null;
1451
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1452
+
1453
+		// make the call
1454
+		return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true);
1455
+	}
1456
+
1457
+	/**
1458
+	 * Add a member to a list. The authenticated user must own the list to be able to add members to it. Lists are limited to having 500 members.
1459
+	 *
1460
+	 * @return    array
1461
+	 * @param    string $user   The user.
1462
+	 * @param    string $id     The id of the list.
1463
+	 * @param    string $userId The id or screen name of the user to add as a member of the list.
1464
+	 */
1465
+	public function userListMembersCreate($user, $id, $userId)
1466
+	{
1467
+		// build parameters
1468
+		$parameters['id'] = (string)$userId;
1469
+
1470
+		// make the call
1471
+		return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true, 'POST');
1472
+	}
1473
+
1474
+	/**
1475
+	 * Removes the specified member from the list. The authenticated user must be the list's owner to remove members from the list.
1476
+	 *
1477
+	 * @return    mixed
1478
+	 * @param    string $user   The user.
1479
+	 * @param    string $id     The id of the list.
1480
+	 * @param    string $userId Specfies the ID of the user for whom to return results for.
1481
+	 */
1482
+	public function userListMembersDelete($user, $id, $userId)
1483
+	{
1484
+		// build parameters
1485
+		$parameters['id']      = (string)$userId;
1486
+		$parameters['_method'] = 'DELETE';
1487
+
1488
+		// make the call
1489
+		return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true, 'POST');
1490
+	}
1491
+
1492
+	/**
1493
+	 * Check if a user is a member of the specified list.
1494
+	 *
1495
+	 *
1496
+	 * @param    string $user   The user.
1497
+	 * @param    string $id     The id of the list.
1498
+	 * @param    string $userId Specfies the ID of the user for whom to return results for.
1499
+	 * @return mixed
1500
+	 * @throws TwitterException
1501
+	 */
1502
+	public function userListMembersId($user, $id, $userId)
1503
+	{
1504
+		try {
1505
+			// make the call
1506
+			return (array)$this->doCall((string)$user . '/' . (string)$id . '/members/' . (string)$userId . '.json', null, true);
1507
+		} // catch exceptions
1508
+		catch (TwitterException $e) {
1509
+			if ($e->getMessage() === 'The specified user is not a member of this list') {
1510
+				return false;
1511
+			} else throw $e;
1512
+		}
1513
+	}
1514
+
1515
+
1516
+	// List Subscribers resources
1517
+	/**
1518
+	 * Returns the subscribers of the specified list.
1519
+	 *
1520
+	 * @return    array
1521
+	 * @param    string $user  The user.
1522
+	 * @param    string $id    The id of the list.
1523
+	 * @param           string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1524
+	 */
1525
+	public function userListSubscribers($user, $id, $cursor = null)
1526
+	{
1527
+		$parameters = null;
1528
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1529
+
1530
+		// make the call
1531
+		return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', $parameters, true);
1532
+	}
1533
+
1534
+	/**
1535
+	 * Make the authenticated user follow the specified list.
1536
+	 *
1537
+	 * @return    array
1538
+	 * @param    string $user The user.
1539
+	 * @param    string $id   The id of the list.
1540
+	 */
1541
+	public function userListSubscribersCreate($user, $id)
1542
+	{
1543
+		// make the call
1544
+		return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', null, true, 'POST');
1545
+	}
1546
+
1547
+	/**
1548
+	 * Unsubscribes the authenticated user form the specified list.
1549
+	 *
1550
+	 * @return    array
1551
+	 * @param    string $user The user.
1552
+	 * @param    string $id   The id of the list.
1553
+	 */
1554
+	public function userListSubscribersDelete($user, $id)
1555
+	{
1556
+		// build parameters
1557
+		$parameters['_method'] = 'DELETE';
1558
+
1559
+		// make the call
1560
+		return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', $parameters, true, 'POST');
1561
+	}
1562
+
1563
+	/**
1564
+	 * Check if the specified user is a subscriber of the specified list.
1565
+	 *
1566
+	 *
1567
+	 * @param    string $user   The user.
1568
+	 * @param    string $id     The id of the list.
1569
+	 * @param    string $userId Specfies the ID of the user for whom to return results for.
1570
+	 * @return mixed
1571
+	 * @throws TwitterException
1572
+	 */
1573
+	public function userListSubscribersId($user, $id, $userId)
1574
+	{
1575
+		try {
1576
+			// make the call
1577
+			return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers/' . (string)$userId . '.json', null, true);
1578
+		} // catch exceptions
1579
+		catch (TwitterException $e) {
1580
+			if ($e->getMessage() === 'The specified user is not a subscriber of this list') {
1581
+				return false;
1582
+			} else throw $e;
1583
+		}
1584
+
1585
+	}
1586
+
1587
+
1588
+	// Direct Messages resources
1589
+	/**
1590
+	 * Returns a list of the 20 most recent direct messages sent to the authenticating user.
1591
+	 *
1592
+	 *
1593
+	 * @param null $sinceId
1594
+	 * @param null $maxId
1595
+	 * @param null $count
1596
+	 * @param null $page
1597
+	 * @return array
1598
+	 * @throws TwitterException
1599
+	 * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
1600
+	 * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
1601
+	 * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
1602
+	 * @internal param $int [optional] $page            Specifies the page of results to retrieve.
1603
+	 */
1604
+	public function directMessages($sinceId = null, $maxId = null, $count = null, $page = null)
1605
+	{
1606
+		// validate
1607
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1608
+
1609
+		// build parameters
1610
+		$parameters = array();
1611
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1612
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1613
+		if ($count != null) $parameters['count'] = (int)$count;
1614
+		if ($page != null) $parameters['page'] = (int)$page;
1615
+
1616
+		// make the call
1617
+		return (array)$this->doCall('direct_messages.json', $parameters, true);
1618
+	}
1619
+
1620
+	/**
1621
+	 * Returns a list of the 20 most recent direct messages sent by the authenticating user.
1622
+	 *
1623
+	 *
1624
+	 * @param null $sinceId
1625
+	 * @param null $maxId
1626
+	 * @param null $count
1627
+	 * @param null $page
1628
+	 * @return array
1629
+	 * @throws TwitterException
1630
+	 * @internal param $string [optional] $sinceId    Returns results with an ID greater than (that is, more recent than) the specified ID.
1631
+	 * @internal param $string [optional] $maxId        Returns results with an ID less than (that is, older than) or equal to the specified ID.
1632
+	 * @internal param $int [optional] $count        Specifies the number of records to retrieve. May not be greater than 200.
1633
+	 * @internal param $int [optional] $page            Specifies the page of results to retrieve.
1634
+	 */
1635
+	public function directMessagesSent($sinceId = null, $maxId = null, $count = null, $page = null)
1636
+	{
1637
+		// validate
1638
+		if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1639
+
1640
+		// build parameters
1641
+		$parameters = array();
1642
+		if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1643
+		if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1644
+		if ($count != null) $parameters['count'] = (int)$count;
1645
+		if ($page != null) $parameters['page'] = (int)$page;
1646
+
1647
+		// make the call
1648
+		return (array)$this->doCall('direct_messages/sent.json', $parameters, true);
1649
+	}
1650
+
1651
+	/**
1652
+	 * Sends a new direct message to the specified user from the authenticating user.
1653
+	 * Requires both the user and text parameters. Returns the sent message in the requested format when successful.
1654
+	 *
1655
+	 *
1656
+	 * @param    string $text The text of your direct message. Be sure to URL encode as necessary, and keep it under 140 characters.
1657
+	 * @param null      $id
1658
+	 * @param null      $userId
1659
+	 * @param null      $screenName
1660
+	 * @return array
1661
+	 * @throws TwitterException
1662
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1663
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1664
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1665
+	 */
1666
+	public function directMessagesNew($text, $id = null, $userId = null, $screenName = null)
1667
+	{
1668
+		// validate
1669
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1670
+
1671
+		// build parameters
1672
+		$parameters['text'] = (string)$text;
1673
+		if ($id != null) $parameters['user'] = (string)$id;
1674
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
1675
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1676
+
1677
+		// make the call
1678
+		return (array)$this->doCall('direct_messages/new.json', $parameters, true, 'POST');
1679
+	}
1680
+
1681
+	/**
1682
+	 * Destroys the direct message specified in the required ID parameter. The authenticating user must be the recipient of the specified direct message.
1683
+	 *
1684
+	 * @return    array
1685
+	 * @param    string $id The ID of the desired direct message.
1686
+	 */
1687
+	public function directMessagesDestroy($id)
1688
+	{
1689
+		// build parameters
1690
+		$parameters['id'] = (string)$id;
1691
+
1692
+		// make the call
1693
+		return (array)$this->doCall('direct_messages/destroy.json', $parameters, true, 'POST');
1694
+	}
1695
+
1696
+
1697
+	// Friendship resources
1698
+	/**
1699
+	 * Allows the authenticating users to follow the user specified in the ID parameter.
1700
+	 * Returns the befriended user in the requested format when successful.
1701
+	 * Returns a string describing the failure condition when unsuccessful.
1702
+	 *
1703
+	 *
1704
+	 * @param null $id
1705
+	 * @param null $userId
1706
+	 * @param null $screenName
1707
+	 * @param bool $follow
1708
+	 * @return mixed
1709
+	 * @throws TwitterException
1710
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1711
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1712
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1713
+	 * @internal param $bool [optional] $follow            Returns public statuses that reference the given set of users.
1714
+	 */
1715
+	public function friendshipsCreate($id = null, $userId = null, $screenName = null, $follow = false)
1716
+	{
1717
+		// validate
1718
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1719
+
1720
+		// build parameters
1721
+		if ($id != null) $parameters['id'] = (string)$id;
1722
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
1723
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1724
+		$parameters['follow'] = $follow ? 'true' : 'false';
1725
+
1726
+		// make the call
1727
+		return (array)$this->doCall('friendships/create.json', $parameters, true, 'POST');
1728
+	}
1729
+
1730
+	/**
1731
+	 * Allows the authenticating users to unfollow the user specified in the ID parameter.
1732
+	 * Returns the unfollowed user in the requested format when successful. Returns a string describing the failure condition when unsuccessful.
1733
+	 *
1734
+	 *
1735
+	 * @param null $id
1736
+	 * @param null $userId
1737
+	 * @param null $screenName
1738
+	 * @return array
1739
+	 * @throws TwitterException
1740
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1741
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1742
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1743
+	 */
1744
+	public function friendshipsDestroy($id = null, $userId = null, $screenName = null)
1745
+	{
1746
+		// validate
1747
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1748
+
1749
+		// build parameters
1750
+		if ($id != null) $parameters['id'] = (string)$id;
1751
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
1752
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1753
+
1754
+		// make the call
1755
+		return (array)$this->doCall('friendships/destroy.json', $parameters, true, 'POST');
1756
+	}
1757
+
1758
+	/**
1759
+	 * Tests for the existence of friendship between two users. Will return true if user_a follows user_b, otherwise will return false.
1760
+	 *
1761
+	 * @return    bool
1762
+	 * @param    string $userA The ID or screen_name of the subject user.
1763
+	 * @param    string $userB The ID or screen_name of the user to test for following.
1764
+	 */
1765
+	public function friendshipsExists($userA, $userB)
1766
+	{
1767
+		// build parameters
1768
+		$parameters['user_a'] = (string)$userA;
1769
+		$parameters['user_b'] = (string)$userB;
1770
+
1771
+		// make the call
1772
+		return (bool)$this->doCall('friendships/exists.json', $parameters);
1773
+	}
1774
+
1775
+	/**
1776
+	 * Returns detailed information about the relationship between two users.
1777
+	 *
1778
+	 *
1779
+	 * @param null $sourceId
1780
+	 * @param null $sourceScreenName
1781
+	 * @param null $targetId
1782
+	 * @param null $targetScreenName
1783
+	 * @return array
1784
+	 * @throws TwitterException
1785
+	 * @internal param $string [optional] $sourceId                The user_id of the subject user.
1786
+	 * @internal param $string [optional] $sourceScreenName        The screen_name of the subject user.
1787
+	 * @internal param $string [optional] $targetId                The screen_name of the subject user.
1788
+	 * @internal param $string [optional] $targetScreenName        The screen_name of the target user.
1789
+	 */
1790
+	public function friendshipsShow($sourceId = null, $sourceScreenName = null, $targetId = null, $targetScreenName = null)
1791
+	{
1792
+		// validate
1793
+		if ($sourceId == '' && $sourceScreenName == '') throw new TwitterException('Specify an sourceId or a sourceScreenName.');
1794
+		if ($targetId == '' && $targetScreenName == '') throw new TwitterException('Specify an targetId or a targetScreenName.');
1795
+
1796
+		// build parameters
1797
+		if ($sourceId != null) $parameters['source_id'] = (string)$sourceId;
1798
+		if ($sourceScreenName != null) $parameters['source_screen_name'] = (string)$sourceScreenName;
1799
+		if ($targetId != null) $parameters['target_id'] = (string)$targetId;
1800
+		if ($targetScreenName != null) $parameters['target_screen_name'] = (string)$targetScreenName;
1801
+
1802
+		// make the call
1803
+		return (array)$this->doCall('friendships/show.json', $parameters);
1804
+	}
1805
+
1806
+	/**
1807
+	 * Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user.
1808
+	 *
1809
+	 * @return    array
1810
+	 * @param    string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1811
+	 */
1812
+	public function friendshipsIncoming($cursor = null)
1813
+	{
1814
+		$parameters = null;
1815
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1816
+
1817
+		// make the call
1818
+		return (array)$this->doCall('friendships/incoming.json', $parameters, true);
1819
+	}
1820
+
1821
+	/**
1822
+	 * Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request.
1823
+	 *
1824
+	 * @return    array
1825
+	 * @param    string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1826
+	 */
1827
+	public function friendshipsOutgoing($cursor = null)
1828
+	{
1829
+		$parameters = null;
1830
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1831
+
1832
+		// make the call
1833
+		return (array)$this->doCall('friendships/outgoing.json', $parameters, true);
1834
+	}
1835
+
1836
+
1837
+	// Friends and Followers resources
1838
+	/**
1839
+	 * Returns an array of numeric IDs for every user the specified user is following.
1840
+	 *
1841
+	 *
1842
+	 * @param null $id
1843
+	 * @param null $userId
1844
+	 * @param null $screenName
1845
+	 * @param null $cursor
1846
+	 * @return array
1847
+	 * @throws TwitterException
1848
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1849
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1850
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1851
+	 * @internal param $string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1852
+	 */
1853
+	public function friendsIds($id = null, $userId = null, $screenName = null, $cursor = null)
1854
+	{
1855
+		// validate
1856
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1857
+
1858
+		// build parameters
1859
+		if ($id != null) $parameters['id'] = (string)$id;
1860
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
1861
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1862
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1863
+
1864
+		// make the call
1865
+		return (array)$this->doCall('friends/ids.json', $parameters);
1866
+	}
1867
+
1868
+	/**
1869
+	 * Returns an array of numeric IDs for every user following the specified user.
1870
+	 *
1871
+	 *
1872
+	 * @param null $id
1873
+	 * @param null $userId
1874
+	 * @param null $screenName
1875
+	 * @param null $cursor
1876
+	 * @return array
1877
+	 * @throws TwitterException
1878
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
1879
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
1880
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
1881
+	 * @internal param $string [optional] $cursor    Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1  to begin paging. Provide values as returned to in the response body's next_cursor  and previous_cursor attributes to page back and forth in the list.
1882
+	 */
1883
+	public function followersIds($id = null, $userId = null, $screenName = null, $cursor = null)
1884
+	{
1885
+		// validate
1886
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1887
+
1888
+		// build parameters
1889
+		if ($id != null) $parameters['id'] = (string)$id;
1890
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
1891
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1892
+		if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1893
+
1894
+		// make the call
1895
+		return (array)$this->doCall('followers/ids.json', $parameters);
1896
+	}
1897
+
1898
+
1899
+	// Account resources
1900
+	/**
1901
+	 * Returns an HTTP 200 OK response code and a representation of the requesting user if authentication was successful; returns a 401 status code and an error message if not. Use this method to test if supplied user credentials are valid.
1902
+	 *
1903
+	 * @return    array
1904
+	 */
1905
+	public function accountVerifyCredentials()
1906
+	{
1907
+		// make the call
1908
+		return (array)$this->doCall('account/verify_credentials.json', null, true);
1909
+	}
1910
+
1911
+	/**
1912
+	 *
1913
+	 * @return    array
1914
+	 */
1915
+	public function accountRateLimitStatus()
1916
+	{
1917
+		// make the call
1918
+		return (array)$this->doCall('account/rate_limit_status.json', null);
1919
+	}
1920
+
1921
+	/**
1922
+	 * Ends the session of the authenticating user, returning a null cookie. Use this method to sign users out of client-facing applications like widgets.
1923
+	 * @return bool
1924
+	 * @throws TwitterException
1925
+	 */
1926
+	public function accountEndSession()
1927
+	{
1928
+		try {
1929
+			// make the call
1930
+			$this->doCall('account/end_session.json', null, true, 'POST');
1931
+		} // catch exceptions
1932
+		catch (TwitterException $e) {
1933
+			if ($e->getMessage() === 'Logged out.') {
1934
+				return true;
1935
+			} else throw $e;
1936
+		}
1937
+	}
1938
+
1939
+	/**
1940
+	 * Sets which device Twitter delivers updates to for the authenticating user. Sending none as the device parameter will disable IM or SMS updates.
1941
+	 *
1942
+	 * @return    array
1943
+	 * @param    string $device Delivery device type to send updates to.
1944
+	 */
1945
+	public function accountUpdateDeliveryDevices($device)
1946
+	{
1947
+		// build parameters
1948
+		$parameters['device'] = (string)$device;
1949
+
1950
+		// make the call
1951
+		return (array)$this->doCall('account/update_delivery_device.json', $parameters, true, 'POST');
1952
+	}
1953
+
1954
+	/**
1955
+	 * Sets one or more hex values that control the color scheme of the authenticating user's profile page on twitter.com.
1956
+	 * Each parameter's value must be a valid hexidecimal value, and may be either three or six characters (ex: #fff or #ffffff).
1957
+	 *
1958
+	 *
1959
+	 * @param null $profileBackgroundColor
1960
+	 * @param null $profileTextColor
1961
+	 * @param null $profileLinkColor
1962
+	 * @param null $profileSidebarFillColor
1963
+	 * @param null $profileSidebarBorderColor
1964
+	 * @return array
1965
+	 * @throws TwitterException
1966
+	 * @internal param $string [optional] $profileBackgroundColor        Profile background color.
1967
+	 * @internal param $string [optional] $profileTextColor                Profile text color.
1968
+	 * @internal param $string [optional] $profileLinkColor                Profile link color.
1969
+	 * @internal param $string [optional] $profileSidebarFillColor        Profile sidebar's background color.
1970
+	 * @internal param $string [optional] $profileSidebarBorderColor        Profile sidebar's border color.
1971
+	 */
1972
+	public function accountUpdateProfileColors($profileBackgroundColor = null, $profileTextColor = null, $profileLinkColor = null, $profileSidebarFillColor = null, $profileSidebarBorderColor = null)
1973
+	{
1974
+		// validate
1975
+		if ($profileBackgroundColor == '' && $profileTextColor == '' && $profileLinkColor == '' && $profileSidebarFillColor == ''
1976
+			&& $profileSidebarBorderColor == ''
1977
+		) throw new TwitterException('Specify a profileBackgroundColor, profileTextColor, profileLinkColor, profileSidebarFillColor or a profileSidebarBorderColor.');
1978
+
1979
+		// build parameters
1980
+		if ($profileBackgroundColor != null) $parameters['profile_background_color'] = (string)$profileBackgroundColor;
1981
+		if ($profileTextColor != null) $parameters['profile_text_color'] = (string)$profileTextColor;
1982
+		if ($profileLinkColor != null) $parameters['profile_link_color'] = (string)$profileLinkColor;
1983
+		if ($profileSidebarFillColor != null) $parameters['profile_sidebar_fill_color'] = (string)$profileSidebarFillColor;
1984
+		if ($profileSidebarBorderColor != null) $parameters['profile_sidebar_border_color'] = (string)$profileSidebarBorderColor;
1985
+
1986
+		// make the call
1987
+		return (array)$this->doCall('account/update_profile_colors.json', $parameters, true, 'POST');
1988
+	}
1989
+
1990
+	/**
1991
+	 * Updates the authenticating user's profile image.
1992
+	 *
1993
+	 *
1994
+	 * @param    string $image The path to the avatar image for the profile. Must be a valid GIF, JPG, or PNG image of less than 700 kilobytes in size. Images with width larger than 500 pixels will be scaled down.
1995
+	 * @return array
1996
+	 * @throws TwitterException
1997
+	 */
1998
+	public function accountUpdateProfileImage($image)
1999
+	{
2000
+		throw new TwitterException('Not implemented');
2001
+
2002
+		// validate
2003
+		if (!file_exists($image)) throw new TwitterException('Image (' . $image . ') doesn\'t exists.');
2004
+
2005
+		// make the call
2006
+		return (array)$this->doCall('account/update_profile_image.json', null, true, 'POST', $image);
2007
+	}
2008
+
2009
+	/**
2010
+	 * Updates the authenticating user's profile background image.
2011
+	 *
2012
+	 *
2013
+	 * @param    string $image The path to the background image for the profile. Must be a valid GIF, JPG, or PNG image of less than 800 kilobytes in size. Images with width larger than 2048 pixels will be forceably scaled down.
2014
+	 * @param    bool   $tile  Whether or not to tile the background image. If set to true the background image will be displayed tiled. The image will not be tiled otherwise.
2015
+	 * @return array
2016
+	 * @throws TwitterException
2017
+	 */
2018
+	public function accountUpdateProfileBackgroundImage($image, $tile = false)
2019
+	{
2020
+		throw new TwitterException('Not implemented');
2021
+
2022
+		// validate
2023
+		if (!file_exists($image)) throw new TwitterException('Image (' . $image . ') doesn\'t exists.');
2024
+
2025
+		// build parameters
2026
+		if ($tile) $parameters['tile'] = 'true';
2027
+
2028
+		// make the call
2029
+		return (array)$this->doCall('account/update_profile_background_image.json', $parameters, true, 'POST', $image);
2030
+	}
2031
+
2032
+	/**
2033
+	 * Sets values that users are able to set under the "Account" tab of their settings page. Only the parameters specified will be updated.
2034
+	 *
2035
+	 * @return    array
2036
+	 * @param    string [optional] $name            Full name associated with the profile. Maximum of 20 characters.
2037
+	 * @param    string [optional] $url            URL associated with the profile. Will be prepended with "http://" if not present. Maximum of 100 characters.
2038
+	 * @param    string [optional] $location        The city or country describing where the user of the account is located. The contents are not normalized or geocoded in any way. Maximum of 30 characters.
2039
+	 * @param    string [optional] $description    A description of the user owning the account. Maximum of 160 characters.
2040
+	 */
2041
+	public function accountUpdateProfile($name = null, $url = null, $location = null, $description = null)
2042
+	{
2043
+		// build parameters
2044
+		$parameters = null;
2045
+		if ($name != null) $parameters['name'] = (string)$name;
2046
+		if ($url != null) $parameters['url'] = (string)$url;
2047
+		if ($location != null) $parameters['location'] = (string)$location;
2048
+		if ($description != null) $parameters['description'] = (string)$description;
2049
+
2050
+		// make the call
2051
+		return (array)$this->doCall('account/update_profile.json', $parameters, true, 'POST');
2052
+	}
2053
+
2054
+
2055
+	// Favorites resources
2056
+	/**
2057
+	 * Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter in the requested format.
2058
+	 *
2059
+	 * @return    array
2060
+	 * @param    string [optional] $id    Specifies the ID or screen name of the user for whom to return results for.
2061
+	 * @param    int    [optional] $page        Specifies the page of results to retrieve.
2062
+	 */
2063
+	public function favorites($id = null, $page = null)
2064
+	{
2065
+		// build parameters
2066
+		$parameters = null;
2067
+		if ($id != null) $parameters['id'] = (string)$id;
2068
+		if ($page != null) $parameters['page'] = (int)$page;
2069
+
2070
+		// make the call
2071
+		return (array)$this->doCall('favorites.json', $parameters, true);
2072
+	}
2073
+
2074
+	/**
2075
+	 * Favorites the status specified in the ID parameter as the authenticating user. Returns the favorite status when successful.
2076
+	 *
2077
+	 * @return    array
2078
+	 * @param    string $id The numerical ID of the desired status.
2079
+	 */
2080
+	public function favoritesCreate($id)
2081
+	{
2082
+		// make the call
2083
+		return (array)$this->doCall('favorites/create/' . $id . '.json', null, true, 'POST');
2084
+	}
2085
+
2086
+	/**
2087
+	 * Un-favorites the status specified in the ID parameter as the authenticating user. Returns the un-favorited status in the requested format when successful.
2088
+	 *
2089
+	 * @return    array
2090
+	 * @param    string $id The numerical ID of the desired status.
2091
+	 */
2092
+	public function favoritesDestroy($id)
2093
+	{
2094
+		// make the call
2095
+		return (array)$this->doCall('favorites/destroy/' . $id . '.json', null, true, 'POST');
2096
+	}
2097
+
2098
+
2099
+	// Notification resources
2100
+	/**
2101
+	 * Enables device notifications for updates from the specified user. Returns the specified user when successful.
2102
+	 *
2103
+	 *
2104
+	 * @param null $id
2105
+	 * @param null $userId
2106
+	 * @param null $screenName
2107
+	 * @return array
2108
+	 * @throws TwitterException
2109
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2110
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2111
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2112
+	 */
2113
+	public function notificationsFollow($id = null, $userId = null, $screenName = null)
2114
+	{
2115
+		// validate
2116
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2117
+
2118
+		// build parameters
2119
+		if ($id != null) $parameters['id'] = (string)$id;
2120
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
2121
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2122
+
2123
+		// make the call
2124
+		return (array)$this->doCall('notifications/follow.json', $parameters, true, 'POST');
2125
+	}
2126
+
2127
+	/**
2128
+	 * Disables notifications for updates from the specified user to the authenticating user. Returns the specified user when successful.
2129
+	 *
2130
+	 *
2131
+	 * @param null $id
2132
+	 * @param null $userId
2133
+	 * @param null $screenName
2134
+	 * @return array
2135
+	 * @throws TwitterException
2136
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2137
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2138
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2139
+	 */
2140
+	public function notificationsLeave($id = null, $userId = null, $screenName = null)
2141
+	{
2142
+		// validate
2143
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2144
+
2145
+		// build parameters
2146
+		if ($id != null) $parameters['id'] = (string)$id;
2147
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
2148
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2149
+
2150
+		// make the call
2151
+		return (array)$this->doCall('notifications/leave.json', $parameters, true, 'POST');
2152
+	}
2153
+
2154
+
2155
+	// Block resources
2156
+	/**
2157
+	 * Blocks the user specified in the ID parameter as the authenticating user. Destroys a friendship to the blocked user if it exists. Returns the blocked user in the requested format when successful.
2158
+	 *
2159
+	 *
2160
+	 * @param null $id
2161
+	 * @param null $userId
2162
+	 * @param null $screenName
2163
+	 * @return array
2164
+	 * @throws TwitterException
2165
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2166
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2167
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2168
+	 */
2169
+	public function blocksCreate($id = null, $userId = null, $screenName = null)
2170
+	{
2171
+		// validate
2172
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2173
+
2174
+		// build parameters
2175
+		if ($id != null) $parameters['id'] = (string)$id;
2176
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
2177
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2178
+
2179
+		// make the call
2180
+		return (array)$this->doCall('blocks/create.json', $parameters, true, 'POST');
2181
+	}
2182
+
2183
+	/**
2184
+	 * Un-blocks the user specified in the ID parameter for the authenticating user. Returns the un-blocked user in the requested format when successful.
2185
+	 *
2186
+	 *
2187
+	 * @param null $id
2188
+	 * @param null $userId
2189
+	 * @param null $screenName
2190
+	 * @return array
2191
+	 * @throws TwitterException
2192
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2193
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2194
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2195
+	 */
2196
+	public function blocksDestroy($id = null, $userId = null, $screenName = null)
2197
+	{
2198
+		// validate
2199
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2200
+
2201
+		// build parameters
2202
+		if ($id != null) $parameters['id'] = (string)$id;
2203
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
2204
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2205
+
2206
+		// make the call
2207
+		return (array)$this->doCall('blocks/destroy.json', $parameters, true, 'POST');
2208
+	}
2209
+
2210
+	/**
2211
+	 * Un-blocks the user specified in the ID parameter for the authenticating user. Returns the un-blocked user in the requested format when successful.
2212
+	 *
2213
+	 *
2214
+	 * @param null $id
2215
+	 * @param null $userId
2216
+	 * @param null $screenName
2217
+	 * @return mixed
2218
+	 * @throws TwitterException
2219
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2220
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2221
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2222
+	 */
2223
+	public function blocksExists($id = null, $userId = null, $screenName = null)
2224
+	{
2225
+		// validate
2226
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2227
+
2228
+		// build parameters
2229
+		if ($id != null) $parameters['id'] = (string)$id;
2230
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
2231
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2232
+
2233
+		try {
2234
+			// make the call
2235
+			return (array)$this->doCall('blocks/exists.json', $parameters, true);
2236
+		} // catch exceptions
2237
+		catch (TwitterException $e) {
2238
+			if ($e->getMessage() === 'You are not blocking this user.') {
2239
+				return false;
2240
+			} else throw $e;
2241
+		}
2242
+	}
2243
+
2244
+	/**
2245
+	 * Returns an array of user objects that the authenticating user is blocking.
2246
+	 *
2247
+	 * @return    array
2248
+	 * @param    int [optional] $page        Specifies the page of results to retrieve. Note: there are pagination limits. See the FAQ for details.
2249
+	 */
2250
+	public function blocksBlocking($page = null)
2251
+	{
2252
+		// build parameters
2253
+		$parameters = null;
2254
+		if ($page != null) $parameters['page'] = (int)$page;
2255
+
2256
+		// make the call
2257
+		return (array)$this->doCall('blocks/blocking.json', $parameters, true);
2258
+	}
2259
+
2260
+	/**
2261
+	 * Returns an array of numeric user ids the authenticating user is blocking.
2262
+	 *
2263
+	 * @return    array
2264
+	 */
2265
+	public function blocksBlockingIds()
2266
+	{
2267
+		// make the call
2268
+		return (array)$this->doCall('blocks/blocking/ids.json', null, true);
2269
+	}
2270
+
2271
+
2272
+	// Spam Reporting resources
2273
+	/**
2274
+	 * The user specified in the id is blocked by the authenticated user and reported as a spammer.
2275
+	 *
2276
+	 *
2277
+	 * @param null $id
2278
+	 * @param null $userId
2279
+	 * @param null $screenName
2280
+	 * @return array
2281
+	 * @throws TwitterException
2282
+	 * @internal param $string [optional] $id            Specifies the ID or screen name of the user for whom to return results for.
2283
+	 * @internal param $string [optional] $userId        Specfies the screen name of the user for whom to return results for. Helpful for disambiguating when a valid screen name is also a user ID.
2284
+	 * @internal param $string [optional] $screenName    Specfies the ID of the user for whom to return results for. Helpful for disambiguating when a valid user ID is also a valid screen name.
2285
+	 */
2286
+	public function reportSpam($id = null, $userId = null, $screenName = null)
2287
+	{
2288
+		// validate
2289
+		if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2290
+
2291
+		// build parameters
2292
+		if ($id != null) $parameters['id'] = (string)$id;
2293
+		if ($userId != null) $parameters['user_id'] = (string)$userId;
2294
+		if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2295
+
2296
+		// make the call
2297
+		return (array)$this->doCall('report_spam.json', $parameters, true, 'POST');
2298
+	}
2299
+
2300
+
2301
+	// Saved Searches resources
2302
+	/**
2303
+	 * Returns the authenticated user's saved search queries.
2304
+	 *
2305
+	 * @return    array
2306
+	 */
2307
+	public function savedSearches()
2308
+	{
2309
+		// make the call
2310
+		return (array)$this->doCall('saved_searches.json', null, true);
2311
+	}
2312
+
2313
+	/**
2314
+	 * Retrieve the data for a saved search owned by the authenticating user specified by the given id.
2315
+	 *
2316
+	 * @return    array
2317
+	 * @param    string $id The ID of the desired saved search.
2318
+	 */
2319
+	public function savedSearchesShow($id)
2320
+	{
2321
+		// build parameters
2322
+		$parameters['id'] = (string)$id;
2323
+
2324
+		// make the call
2325
+		return (array)$this->doCall('saved_searches/show.json', $parameters, true);
2326
+	}
2327
+
2328
+	/**
2329
+	 * Creates a saved search for the authenticated user.
2330
+	 *
2331
+	 * @return    array
2332
+	 * @param    string $query The query of the search the user would like to save.
2333
+	 */
2334
+	public function savedSearchesCreate($query)
2335
+	{
2336
+		// build parameters
2337
+		$parameters['query'] = (string)$query;
2338
+
2339
+		// make the call
2340
+		return (array)$this->doCall('saved_searches/create.json', $parameters, true, 'POST');
2341
+	}
2342
+
2343
+	/**
2344
+	 * Destroys a saved search for the authenticated user. The search specified by id must be owned by the authenticating user.
2345
+	 * REMARK: This method seems not to work    @later
2346
+	 *
2347
+	 * @return    array
2348
+	 * @param    string $id The ID of the desired saved search.
2349
+	 */
2350
+	public function savedSearchesDestroy($id)
2351
+	{
2352
+		return (array)$this->doCall('saved_searches/destroy/' . (string)$id . '.json', null, true, 'POST');
2353
+	}
2354
+
2355
+
2356
+	// OAuth resources
2357
+	/**
2358
+	 * Allows a Consumer application to obtain an OAuth Request Token to request user authorization.
2359
+	 * This method fulfills Secion 6.1 of the OAuth 1.0 authentication flow.
2360
+	 *
2361
+	 *
2362
+	 * @param    string $callbackURL
2363
+	 * @return array An array containg the token and the secret
2364
+	 * @throws TwitterException
2365
+	 */
2366
+	public function oAuthRequestToken($callbackURL = null)
2367
+	{
2368
+		// init var
2369
+		$parameters = array();
2370
+
2371
+		// set callback
2372
+		if ($callbackURL != null) $parameters['oauth_callback'] = (string)$callbackURL;
2373
+
2374
+		// make the call
2375
+		$response = $this->doOAuthCall('request_token', $parameters);
2376
+
2377
+		// validate
2378
+		if (!isset($response['oauth_token'], $response['oauth_token_secret'])) throw new TwitterException(implode(', ', array_keys($response)));
2379
+
2380
+		// set some properties
2381
+		if (isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']);
2382
+		if (isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']);
2383
+
2384
+		// return
2385
+		return $response;
2386
+	}
2387
+
2388
+	/**
2389
+	 * Allows a Consumer application to exchange the OAuth Request Token for an OAuth Access Token.
2390
+	 * This method fulfills Secion 6.3 of the OAuth 1.0 authentication flow.
2391
+	 *
2392
+	 * @return    array
2393
+	 * @param    string $token
2394
+	 * @param    string $verifier
2395
+	 */
2396
+	public function oAuthAccessToken($token, $verifier)
2397
+	{
2398
+		// init var
2399
+		$parameters                   = array();
2400
+		$parameters['oauth_token']    = (string)$token;
2401
+		$parameters['oauth_verifier'] = (string)$verifier;
2402
+
2403
+		// make the call
2404
+		$response = $this->doOAuthCall('access_token', $parameters);
2405
+
2406
+		// set some properties
2407
+		if (isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']);
2408
+		if (isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']);
2409
+
2410
+		// return
2411
+		return $response;
2412
+	}
2413
+
2414
+	/**
2415
+	 * Will redirect to the page to authorize the applicatione
2416
+	 *
2417
+	 * @return    void
2418
+	 */
2419
+	public function oAuthAuthorize()
2420
+	{
2421
+		header('Location: ' . self::SECURE_API_URL . '/oauth/authorize?oauth_token=' . $this->oAuthToken);
2422
+	}
2423
+
2424
+	/**
2425
+	 * Allows a Consumer application to use an OAuth request_token to request user authorization. This method is a replacement fulfills Secion 6.2 of the OAuth 1.0 authentication flow for applications using the Sign in with Twitter authentication flow. The method will use the currently logged in user as the account to for access authorization unless the force_login parameter is set to true
2426
+	 * REMARK: This method seems not to work    @later
2427
+	 *
2428
+	 * @return    void
2429
+	 */
2430
+	public function oAuthAuthenticate()
2431
+	{
2432
+		// make the call
2433
+		return $this->doOAuthCall('authenticate');
2434
+	}
2435
+
2436
+
2437
+	// Local Trends resources
2438
+	/**
2439
+	 * Returns the locations that Twitter has trending topic information for.
2440
+	 * The response is an array of "locations" that encode the location's WOEID (a Yahoo! Where On Earth ID) and some other human-readable information such as a canonical name and country the location belongs in.
2441
+	 * The WOEID that is returned in the location object is to be used when querying for a specific trend.
2442
+	 *
2443
+	 * @return    array
2444
+	 * @param    float [optional] $lat    If passed in conjunction with long, then the available trend locations will be sorted by distance to the lat  and long passed in. The sort is nearest to furthest.
2445
+	 * @param    float [optional] $long    If passed in conjunction with lat, then the available trend locations will be sorted by distance to the lat  and long passed in. The sort is nearest to furthest.
2446
+	 */
2447
+	public function trendsAvailable($lat = null, $long = null)
2448
+	{
2449
+		// build parameters
2450
+		$parameters = null;
2451
+		if ($lat != null) $parameters['lat_for_trends'] = (float)$lat;
2452
+		if ($long != null) $parameters['long_for_trends'] = (float)$long;
2453
+
2454
+		// make the call
2455
+		return (array)$this->doCall('trends/available.json', $parameters);
2456
+	}
2457
+
2458
+	/**
2459
+	 * Returns the top 10 trending topics for a specific location Twitter has trending topic information for.
2460
+	 * The response is an array of "trend" objects that encode the name of the trending topic, the query parameter that can be used to search for the topic on Search, and the direct URL that can be issued against Search.
2461
+	 * This information is cached for five minutes, and therefore users are discouraged from querying these endpoints faster than once every five minutes. Global trends information is also available from this API by using a WOEID of 1.
2462
+	 * REMARK: This method seems not to work    @later
2463
+	 *
2464
+	 * @return    array
2465
+	 * @param    string $woeid The WOEID of the location to be querying for.
2466
+	 */
2467
+	public function trendsLocation($woeid)
2468
+	{
2469
+		// make the call
2470
+		return (array)$this->doCall('trends/location/' . (string)$woeid . '.json');
2471
+	}
2472
+
2473
+
2474
+	// Geo resources
2475
+	/**
2476
+	 * Search for places (cities and neighborhoods) that can be attached to a statuses/update. Given a latitude and a longitude, return a list of all the valid places that can be used as a place_id when updating a status.
2477
+	 * Conceptually, a query can be made from the user's location, retrieve a list of places, have the user validate the location he or she is at, and then send the ID of this location up with a call to statuses/update.
2478
+	 * There are multiple granularities of places that can be returned -- "neighborhoods", "cities", etc. At this time, only United States data is available through this method.
2479
+	 * This API call is meant to be an informative call and will deliver generalized results about geography.
2480
+	 *
2481
+	 * @return    array
2482
+	 * @param    float $lat   The location's latitude that this tweet refers to.
2483
+	 * @param    float $long  The location's longitude that this tweet refers to.
2484
+	 * @param          string [optional] $accuracy        A hint on the "region" in which to search. If a number, then this is a radius in meters, but it can also take a string that is suffixed with ft to specify feet. If this is not passed in, then it is assumed to be 0m. If coming from a device, in practice, this value is whatever accuracy the device has measuring its location (whether it be coming from a GPS, WiFi triangulation, etc.).
2485
+	 * @param          string [optional] $granularity    The minimal granularity of data to return. If this is not passed in, then neighborhood is assumed. city can also be passed.
2486
+	 * @param          int    [optional] $maxResults        A hint as to the number of results to return. This does not guarantee that the number of results returned will equal max_results, but instead informs how many "nearby" results to return. Ideally, only pass in the number of places you intend to display to the user here.
2487
+	 */
2488
+	public function geoReverseGeoCode($lat, $long, $accuracy = null, $granularity = null, $maxResults = null)
2489
+	{
2490
+		// build parameters
2491
+		$parameters['lat']  = (float)$lat;
2492
+		$parameters['long'] = (float)$long;
2493
+		if ($accuracy != null) $parameters['accuracy'] = (string)$accuracy;
2494
+		if ($granularity != null) $parameters['granularity'] = (string)$granularity;
2495
+		if ($maxResults != null) $parameters['max_results'] = (int)$maxResults;
2496
+
2497
+		// make the call
2498
+		return (array)$this->doCall('geo/reverse_geocode.json', $parameters);
2499
+	}
2500
+
2501
+	/**
2502
+	 * Find out more details of a place that was returned from the geo/reverse_geocode method.
2503
+	 *
2504
+	 * @return    array
2505
+	 * @param    string $id
2506
+	 * @param           string [optional] $placeId    A place in the world. These IDs can be retrieved from geo/reverse_geocode.
2507
+	 */
2508
+	public function geoId($id, $placeId = null)
2509
+	{
2510
+		// build parameters
2511
+		$parameters = null;
2512
+		if ($placeId != null) $parameters['place_id'] = (string)$placeId;
2513
+
2514
+		// make the call
2515
+		return (array)$this->doCall('geo/id/' . (string)$id . '.json', $parameters);
2516
+	}
2517
+
2518
+
2519
+	// Help resources
2520
+	/**
2521
+	 * Test
2522
+	 * REMARK: this methods seems not to work, so don't rely on it
2523
+	 *
2524
+	 * @return    bool
2525
+	 */
2526
+	public function helpTest()
2527
+	{
2528
+		// make the call
2529
+		return ($this->doCall('help/test', null, null, 'GET', null, false) == 'ok');
2530
+	}
2531 2531
 }
2532 2532
 
2533 2533
 /**
Please login to merge, or discard this patch.
Spacing   +289 added lines, -289 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         }
159 159
 
160 160
         // process parameters
161
-        foreach ($parameters as $key => $value) $chunks[] = $key . '=' . str_replace('%25', '%', $value);
161
+        foreach ($parameters as $key => $value) $chunks[] = $key.'='.str_replace('%25', '%', $value);
162 162
 
163 163
         // return
164 164
         return implode('&', $chunks);
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
     private function calculateBaseString($url, $method, array $parameters)
183 183
     {
184 184
         // redefine
185
-        $url        = (string)$url;
186
-        $parameters = (array)$parameters;
185
+        $url        = (string) $url;
186
+        $parameters = (array) $parameters;
187 187
 
188 188
         // init var
189 189
         $pairs  = array();
@@ -200,12 +200,12 @@  discard block
 block discarded – undo
200 200
 
201 201
         // process queries
202 202
         foreach ($parameters as $key => $value) {
203
-            $chunks[] = self::urlencode_rfc3986($key) . '%3D' . self::urlencode_rfc3986($value);
203
+            $chunks[] = self::urlencode_rfc3986($key).'%3D'.self::urlencode_rfc3986($value);
204 204
         }
205 205
 
206 206
         // buils base
207
-        $base = $method . '&';
208
-        $base .= urlencode($url) . '&';
207
+        $base = $method.'&';
208
+        $base .= urlencode($url).'&';
209 209
         $base .= implode('%26', $chunks);
210 210
 
211 211
         // return
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
     private function calculateHeader(array $parameters, $url = null)
225 225
     {
226 226
         // redefine
227
-        $url = (string)$url;
227
+        $url = (string) $url;
228 228
 
229 229
         // divide into parts
230 230
         $parts = parse_url($url);
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
         $chunks = array();
234 234
 
235 235
         // process queries
236
-        foreach ($parameters as $key => $value) $chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key) . '="' . self::urlencode_rfc3986($value) . '"');
236
+        foreach ($parameters as $key => $value) $chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key).'="'.self::urlencode_rfc3986($value).'"');
237 237
 
238 238
         // build return
239
-        $return = 'Authorization: OAuth realm="' . $parts['scheme'] . '://' . $parts['host'] . $parts['path'] . '", ';
239
+        $return = 'Authorization: OAuth realm="'.$parts['scheme'].'://'.$parts['host'].$parts['path'].'", ';
240 240
         $return .= implode(',', $chunks);
241 241
 
242 242
         // prepend name and OAuth part
@@ -256,31 +256,31 @@  discard block
 block discarded – undo
256 256
     private function doOAuthCall($method, array $parameters = null)
257 257
     {
258 258
         // redefine
259
-        $method = (string)$method;
259
+        $method = (string) $method;
260 260
 
261 261
         // append default parameters
262 262
         $parameters['oauth_consumer_key']     = $this->getConsumerKey();
263
-        $parameters['oauth_nonce']            = md5(microtime() . rand());
263
+        $parameters['oauth_nonce']            = md5(microtime().rand());
264 264
         $parameters['oauth_timestamp']        = time();
265 265
         $parameters['oauth_signature_method'] = 'HMAC-SHA1';
266 266
         $parameters['oauth_version']          = '1.0';
267 267
 
268 268
         // calculate the base string
269
-        $base = $this->calculateBaseString(self::SECURE_API_URL . '/oauth/' . $method, 'POST', $parameters);
269
+        $base = $this->calculateBaseString(self::SECURE_API_URL.'/oauth/'.$method, 'POST', $parameters);
270 270
 
271 271
         // add sign into the parameters
272
-        $parameters['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret() . '&' . $this->getOAuthTokenSecret(), $base);
272
+        $parameters['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret().'&'.$this->getOAuthTokenSecret(), $base);
273 273
 
274 274
         // calculate header
275
-        $header = $this->calculateHeader($parameters, self::SECURE_API_URL . '/oauth/' . $method);
275
+        $header = $this->calculateHeader($parameters, self::SECURE_API_URL.'/oauth/'.$method);
276 276
 
277 277
         // set options
278
-        $options[CURLOPT_URL]            = self::SECURE_API_URL . '/oauth/' . $method;
278
+        $options[CURLOPT_URL]            = self::SECURE_API_URL.'/oauth/'.$method;
279 279
         $options[CURLOPT_PORT]           = self::SECURE_API_PORT;
280 280
         $options[CURLOPT_USERAGENT]      = $this->getUserAgent();
281 281
         $options[CURLOPT_FOLLOWLOCATION] = true;
282 282
         $options[CURLOPT_RETURNTRANSFER] = true;
283
-        $options[CURLOPT_TIMEOUT]        = (int)$this->getTimeOut();
283
+        $options[CURLOPT_TIMEOUT]        = (int) $this->getTimeOut();
284 284
         $options[CURLOPT_SSL_VERIFYPEER] = false;
285 285
         $options[CURLOPT_SSL_VERIFYHOST] = false;
286 286
         $options[CURLOPT_HTTPHEADER]     = array('Expect:');
@@ -336,18 +336,18 @@  discard block
 block discarded – undo
336 336
         $allowedMethods = array('GET', 'POST');
337 337
 
338 338
         // redefine
339
-        $url          = (string)$url;
340
-        $parameters   = (array)$parameters;
341
-        $authenticate = (bool)$authenticate;
342
-        $method       = (string)$method;
343
-        $expectJSON   = (bool)$expectJSON;
339
+        $url          = (string) $url;
340
+        $parameters   = (array) $parameters;
341
+        $authenticate = (bool) $authenticate;
342
+        $method       = (string) $method;
343
+        $expectJSON   = (bool) $expectJSON;
344 344
 
345 345
         // validate method
346
-        if (!in_array($method, $allowedMethods)) throw new TwitterException('Unknown method (' . $method . '). Allowed methods are: ' . implode(', ', $allowedMethods));
346
+        if (!in_array($method, $allowedMethods)) throw new TwitterException('Unknown method ('.$method.'). Allowed methods are: '.implode(', ', $allowedMethods));
347 347
 
348 348
         // append default parameters
349 349
         $oauth['oauth_consumer_key']     = $this->getConsumerKey();
350
-        $oauth['oauth_nonce']            = md5(microtime() . rand());
350
+        $oauth['oauth_nonce']            = md5(microtime().rand());
351 351
         $oauth['oauth_timestamp']        = time();
352 352
         $oauth['oauth_token']            = $this->getOAuthToken();
353 353
         $oauth['oauth_signature_method'] = 'HMAC-SHA1';
@@ -358,12 +358,12 @@  discard block
 block discarded – undo
358 358
         if (!empty($parameters)) $data = array_merge($data, $parameters);
359 359
 
360 360
         // calculate the base string
361
-        $base = $this->calculateBaseString(self::API_URL . '/' . $url, $method, $data);
361
+        $base = $this->calculateBaseString(self::API_URL.'/'.$url, $method, $data);
362 362
 
363 363
         // add sign into the parameters
364
-        $oauth['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret() . '&' . $this->getOAuthTokenSecret(), $base);
364
+        $oauth['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret().'&'.$this->getOAuthTokenSecret(), $base);
365 365
 
366
-        $headers[] = $this->calculateHeader($oauth, self::API_URL . '/' . $url);
366
+        $headers[] = $this->calculateHeader($oauth, self::API_URL.'/'.$url);
367 367
         $headers[] = 'Expect:';
368 368
 
369 369
         // based on the method, we should handle the parameters in a different way
@@ -384,14 +384,14 @@  discard block
 block discarded – undo
384 384
                 elseif ($fileInfo['extension'] === 'png') $mimeType = 'image/png';
385 385
 
386 386
                 // init var
387
-                $content = '--' . $boundary . "\r\n";
387
+                $content = '--'.$boundary."\r\n";
388 388
 
389 389
                 // set file
390
-                $content = 'Content-Disposition: form-data; name="image";filename="' . $fileInfo['basename'] . '"' . "\r\n" . 'Content-Type: ' . $mimeType . "\r\n\r\n" . file_get_contents($filePath) . "\r\n--" . $boundary . "\r\n";
390
+                $content = 'Content-Disposition: form-data; name="image";filename="'.$fileInfo['basename'].'"'."\r\n".'Content-Type: '.$mimeType."\r\n\r\n".file_get_contents($filePath)."\r\n--".$boundary."\r\n";
391 391
 
392 392
                 // build headers
393
-                $headers[] = 'Content-Type: multipart/form-data; boundary=' . $boundary;
394
-                $headers[] = 'Content-Length: ' . strlen($content);
393
+                $headers[] = 'Content-Type: multipart/form-data; boundary='.$boundary;
394
+                $headers[] = 'Content-Length: '.strlen($content);
395 395
 
396 396
                 // set content
397 397
                 $options[CURLOPT_POSTFIELDS] = $content;
@@ -402,16 +402,16 @@  discard block
 block discarded – undo
402 402
             $options[CURLOPT_POST] = 1;
403 403
         } else {
404 404
             // add the parameters into the querystring
405
-            if (!empty($parameters)) $url .= '?' . $this->buildQuery($parameters);
405
+            if (!empty($parameters)) $url .= '?'.$this->buildQuery($parameters);
406 406
         }
407 407
 
408 408
         // set options
409
-        $options[CURLOPT_URL]            = self::API_URL . '/' . $url;
409
+        $options[CURLOPT_URL]            = self::API_URL.'/'.$url;
410 410
         $options[CURLOPT_PORT]           = self::API_PORT;
411 411
         $options[CURLOPT_USERAGENT]      = $this->getUserAgent();
412 412
         $options[CURLOPT_FOLLOWLOCATION] = true;
413 413
         $options[CURLOPT_RETURNTRANSFER] = true;
414
-        $options[CURLOPT_TIMEOUT]        = (int)$this->getTimeOut();
414
+        $options[CURLOPT_TIMEOUT]        = (int) $this->getTimeOut();
415 415
         $options[CURLOPT_SSL_VERIFYPEER] = false;
416 416
         $options[CURLOPT_SSL_VERIFYHOST] = false;
417 417
         $options[CURLOPT_HTTP_VERSION]   = CURL_HTTP_VERSION_1_1;
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
      */
563 563
     public function getTimeOut()
564 564
     {
565
-        return (int)$this->timeOut;
565
+        return (int) $this->timeOut;
566 566
     }
567 567
 
568 568
     /**
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
      */
574 574
     public function getUserAgent()
575 575
     {
576
-        return (string)'PHP Twitter/' . self::VERSION . ' ' . $this->userAgent;
576
+        return (string) 'PHP Twitter/'.self::VERSION.' '.$this->userAgent;
577 577
     }
578 578
 
579 579
     /**
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
      */
585 585
     private function setConsumerKey($key)
586 586
     {
587
-        $this->consumerKey = (string)$key;
587
+        $this->consumerKey = (string) $key;
588 588
     }
589 589
 
590 590
     /**
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
      */
596 596
     private function setConsumerSecret($secret)
597 597
     {
598
-        $this->consumerSecret = (string)$secret;
598
+        $this->consumerSecret = (string) $secret;
599 599
     }
600 600
 
601 601
     /**
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
      */
607 607
     public function setOAuthToken($token)
608 608
     {
609
-        $this->oAuthToken = (string)$token;
609
+        $this->oAuthToken = (string) $token;
610 610
     }
611 611
 
612 612
     /**
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
      */
618 618
     public function setOAuthTokenSecret($secret)
619 619
     {
620
-        $this->oAuthTokenSecret = (string)$secret;
620
+        $this->oAuthTokenSecret = (string) $secret;
621 621
     }
622 622
 
623 623
     /**
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
      */
629 629
     public function setTimeOut($seconds)
630 630
     {
631
-        $this->timeOut = (int)$seconds;
631
+        $this->timeOut = (int) $seconds;
632 632
     }
633 633
 
634 634
     /**
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
      */
641 641
     public function setUserAgent($userAgent)
642 642
     {
643
-        $this->userAgent = (string)$userAgent;
643
+        $this->userAgent = (string) $userAgent;
644 644
     }
645 645
 
646 646
     /**
@@ -685,14 +685,14 @@  discard block
 block discarded – undo
685 685
     public function statusesPublicTimeline($skipUser = false)
686 686
     {
687 687
         // redefine
688
-        $skipUser = (bool)$skipUser;
688
+        $skipUser = (bool) $skipUser;
689 689
 
690 690
         // build parameters
691 691
         $parameters = array();
692 692
         if ($skipUser) $parameters['skip_user'] = 'true';
693 693
 
694 694
         // make the call
695
-        return (array)$this->doCall('statuses/public_timeline.json', $parameters);
695
+        return (array) $this->doCall('statuses/public_timeline.json', $parameters);
696 696
     }
697 697
 
698 698
     /**
@@ -708,18 +708,18 @@  discard block
 block discarded – undo
708 708
     public function statusesHomeTimeline($sinceId = null, $maxId = null, $count = null, $page = null, $skipUser = false)
709 709
     {
710 710
         // redefine
711
-        $skipUser = (bool)$skipUser;
711
+        $skipUser = (bool) $skipUser;
712 712
 
713 713
         // build parameters
714 714
         $parameters = array();
715
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
716
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
717
-        if ($count != null) $parameters['count'] = (int)$count;
718
-        if ($page != null) $parameters['page'] = (int)$page;
715
+        if ($sinceId != null) $parameters['since_id'] = (string) $sinceId;
716
+        if ($maxId != null) $parameters['max_id'] = (string) $maxId;
717
+        if ($count != null) $parameters['count'] = (int) $count;
718
+        if ($page != null) $parameters['page'] = (int) $page;
719 719
         if ($skipUser) $parameters['skip_user'] = 'true';
720 720
 
721 721
         // make the call
722
-        return (array)$this->doCall('statuses/home_timeline.json', $parameters, true);
722
+        return (array) $this->doCall('statuses/home_timeline.json', $parameters, true);
723 723
     }
724 724
 
725 725
     /**
@@ -739,18 +739,18 @@  discard block
 block discarded – undo
739 739
     public function statusesFriendsTimeline($sinceId = null, $maxId = null, $count = null, $page = null, $skipUser = false)
740 740
     {
741 741
         // redefine
742
-        $skipUser = (bool)$skipUser;
742
+        $skipUser = (bool) $skipUser;
743 743
 
744 744
         // build parameters
745 745
         $parameters = array();
746
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
747
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
748
-        if ($count != null) $parameters['count'] = (int)$count;
749
-        if ($page != null) $parameters['page'] = (int)$page;
746
+        if ($sinceId != null) $parameters['since_id'] = (string) $sinceId;
747
+        if ($maxId != null) $parameters['max_id'] = (string) $maxId;
748
+        if ($count != null) $parameters['count'] = (int) $count;
749
+        if ($page != null) $parameters['page'] = (int) $page;
750 750
         if ($skipUser) $parameters['skip_user'] = 'true';
751 751
 
752 752
         // make the call
753
-        return (array)$this->doCall('statuses/friends_timeline.json', $parameters, true);
753
+        return (array) $this->doCall('statuses/friends_timeline.json', $parameters, true);
754 754
     }
755 755
 
756 756
     /**
@@ -773,21 +773,21 @@  discard block
 block discarded – undo
773 773
     public function statusesUserTimeline($id = null, $userId = null, $screenName = null, $sinceId = null, $maxId = null, $count = null, $page = null, $skipUser = false)
774 774
     {
775 775
         // redefine
776
-        $skipUser = (bool)$skipUser;
776
+        $skipUser = (bool) $skipUser;
777 777
 
778 778
         // build parameters
779 779
         $parameters = array();
780
-        if ($id != null) $parameters['id'] = (string)$id;
781
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
782
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
783
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
784
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
785
-        if ($count != null) $parameters['count'] = (int)$count;
786
-        if ($page != null) $parameters['page'] = (int)$page;
780
+        if ($id != null) $parameters['id'] = (string) $id;
781
+        if ($userId != null) $parameters['user_id'] = (string) $userId;
782
+        if ($screenName != null) $parameters['screen_name'] = (string) $screenName;
783
+        if ($sinceId != null) $parameters['since_id'] = (string) $sinceId;
784
+        if ($maxId != null) $parameters['max_id'] = (string) $maxId;
785
+        if ($count != null) $parameters['count'] = (int) $count;
786
+        if ($page != null) $parameters['page'] = (int) $page;
787 787
         if ($skipUser) $parameters['skip_user'] = 'true';
788 788
 
789 789
         // make the call
790
-        return (array)$this->doCall('statuses/user_timeline.json', $parameters, true);
790
+        return (array) $this->doCall('statuses/user_timeline.json', $parameters, true);
791 791
     }
792 792
 
793 793
     /**
@@ -812,13 +812,13 @@  discard block
 block discarded – undo
812 812
 
813 813
         // build parameters
814 814
         $parameters = array();
815
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
816
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
817
-        if ($count != null) $parameters['count'] = (int)$count;
818
-        if ($page != null) $parameters['page'] = (int)$page;
815
+        if ($sinceId != null) $parameters['since_id'] = (string) $sinceId;
816
+        if ($maxId != null) $parameters['max_id'] = (string) $maxId;
817
+        if ($count != null) $parameters['count'] = (int) $count;
818
+        if ($page != null) $parameters['page'] = (int) $page;
819 819
 
820 820
         // make the call
821
-        return (array)$this->doCall('statuses/mentions.json', $parameters);
821
+        return (array) $this->doCall('statuses/mentions.json', $parameters);
822 822
     }
823 823
 
824 824
     /**
@@ -843,13 +843,13 @@  discard block
 block discarded – undo
843 843
 
844 844
         // build parameters
845 845
         $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;
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;
850 850
 
851 851
         // make the call
852
-        return (array)$this->doCall('statuses/retweeted_by_me.json', $parameters);
852
+        return (array) $this->doCall('statuses/retweeted_by_me.json', $parameters);
853 853
     }
854 854
 
855 855
     /**
@@ -874,13 +874,13 @@  discard block
 block discarded – undo
874 874
 
875 875
         // build parameters
876 876
         $parameters = array();
877
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
878
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
879
-        if ($count != null) $parameters['count'] = (int)$count;
880
-        if ($page != null) $parameters['page'] = (int)$page;
877
+        if ($sinceId != null) $parameters['since_id'] = (string) $sinceId;
878
+        if ($maxId != null) $parameters['max_id'] = (string) $maxId;
879
+        if ($count != null) $parameters['count'] = (int) $count;
880
+        if ($page != null) $parameters['page'] = (int) $page;
881 881
 
882 882
         // make the call
883
-        return (array)$this->doCall('statuses/retweeted_by_me.json', $parameters);
883
+        return (array) $this->doCall('statuses/retweeted_by_me.json', $parameters);
884 884
     }
885 885
 
886 886
 
@@ -907,13 +907,13 @@  discard block
 block discarded – undo
907 907
 
908 908
         // build parameters
909 909
         $parameters = array();
910
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
911
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
912
-        if ($count != null) $parameters['count'] = (int)$count;
913
-        if ($page != null) $parameters['page'] = (int)$page;
910
+        if ($sinceId != null) $parameters['since_id'] = (string) $sinceId;
911
+        if ($maxId != null) $parameters['max_id'] = (string) $maxId;
912
+        if ($count != null) $parameters['count'] = (int) $count;
913
+        if ($page != null) $parameters['page'] = (int) $page;
914 914
 
915 915
         // make the call
916
-        return (array)$this->doCall('statuses/retweets_of_me.json', $parameters);
916
+        return (array) $this->doCall('statuses/retweets_of_me.json', $parameters);
917 917
     }
918 918
 
919 919
     /**
@@ -925,10 +925,10 @@  discard block
 block discarded – undo
925 925
     public function statusesShow($id)
926 926
     {
927 927
         // build parameters
928
-        $parameters['id'] = (string)$id;
928
+        $parameters['id'] = (string) $id;
929 929
 
930 930
         // make the call
931
-        return (array)$this->doCall('statuses/show.json', $parameters);
931
+        return (array) $this->doCall('statuses/show.json', $parameters);
932 932
     }
933 933
 
934 934
     /**
@@ -945,15 +945,15 @@  discard block
 block discarded – undo
945 945
     public function statusesUpdate($status, $inReplyToStatusId = null, $lat = null, $long = null, $placeId = null, $displayCoordinates = false)
946 946
     {
947 947
         // build parameters
948
-        $parameters['status'] = (string)$status;
949
-        if ($inReplyToStatusId != null) $parameters['in_reply_to_status_id'] = (string)$inReplyToStatusId;
950
-        if ($lat != null) $parameters['lat'] = (float)$lat;
951
-        if ($long != null) $parameters['long'] = (float)$long;
952
-        if ($placeId != null) $parameters['place_id'] = (string)$placeId;
948
+        $parameters['status'] = (string) $status;
949
+        if ($inReplyToStatusId != null) $parameters['in_reply_to_status_id'] = (string) $inReplyToStatusId;
950
+        if ($lat != null) $parameters['lat'] = (float) $lat;
951
+        if ($long != null) $parameters['long'] = (float) $long;
952
+        if ($placeId != null) $parameters['place_id'] = (string) $placeId;
953 953
         if ($displayCoordinates) $parameters['display_coordinates'] = 'true';
954 954
 
955 955
         // make the call
956
-        return (array)$this->doCall('statuses/update.json', $parameters, true, 'POST');
956
+        return (array) $this->doCall('statuses/update.json', $parameters, true, 'POST');
957 957
     }
958 958
 
959 959
     /**
@@ -966,10 +966,10 @@  discard block
 block discarded – undo
966 966
     public function statusesDestroy($id)
967 967
     {
968 968
         // build parameters
969
-        $parameters['id'] = (string)$id;
969
+        $parameters['id'] = (string) $id;
970 970
 
971 971
         // make the call
972
-        return (array)$this->doCall('statuses/destroy.json', $parameters, true, 'POST');
972
+        return (array) $this->doCall('statuses/destroy.json', $parameters, true, 'POST');
973 973
     }
974 974
 
975 975
     /**
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
     public function statusesRetweet($id)
982 982
     {
983 983
         // make the call
984
-        return (array)$this->doCall('statuses/retweet/' . $id . '.json', null, true, 'POST');
984
+        return (array) $this->doCall('statuses/retweet/'.$id.'.json', null, true, 'POST');
985 985
     }
986 986
 
987 987
     /**
@@ -1000,10 +1000,10 @@  discard block
 block discarded – undo
1000 1000
 
1001 1001
         // build parameters
1002 1002
         $parameters = null;
1003
-        if ($count != null) $parameters['count'] = (int)$count;
1003
+        if ($count != null) $parameters['count'] = (int) $count;
1004 1004
 
1005 1005
         // make the call
1006
-        return (array)$this->doCall('statuses/retweets/' . $id . '.json', $parameters);
1006
+        return (array) $this->doCall('statuses/retweets/'.$id.'.json', $parameters);
1007 1007
     }
1008 1008
 
1009 1009
     /**
@@ -1025,11 +1025,11 @@  discard block
 block discarded – undo
1025 1025
 
1026 1026
         // build parameters
1027 1027
         $parameters = null;
1028
-        if ($count != null) $parameters['count'] = (int)$count;
1029
-        if ($page != null) $parameters['page'] = (int)$page;
1028
+        if ($count != null) $parameters['count'] = (int) $count;
1029
+        if ($page != null) $parameters['page'] = (int) $page;
1030 1030
 
1031 1031
         // make the call
1032
-        return (array)$this->doCall('statuses/' . (string)$id . '/retweeted_by.json', $parameters, true);
1032
+        return (array) $this->doCall('statuses/'.(string) $id.'/retweeted_by.json', $parameters, true);
1033 1033
     }
1034 1034
 
1035 1035
     /**
@@ -1051,11 +1051,11 @@  discard block
 block discarded – undo
1051 1051
 
1052 1052
         // build parameters
1053 1053
         $parameters = null;
1054
-        if ($count != null) $parameters['count'] = (int)$count;
1055
-        if ($page != null) $parameters['page'] = (int)$page;
1054
+        if ($count != null) $parameters['count'] = (int) $count;
1055
+        if ($page != null) $parameters['page'] = (int) $page;
1056 1056
 
1057 1057
         // make the call
1058
-        return (array)$this->doCall('statuses/' . (string)$id . '/retweeted_by/ids.json', $parameters, true);
1058
+        return (array) $this->doCall('statuses/'.(string) $id.'/retweeted_by/ids.json', $parameters, true);
1059 1059
     }
1060 1060
 
1061 1061
 
@@ -1080,12 +1080,12 @@  discard block
 block discarded – undo
1080 1080
         if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1081 1081
 
1082 1082
         // build parameters
1083
-        if ($id != null) $parameters['id'] = (string)$id;
1084
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1085
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1083
+        if ($id != null) $parameters['id'] = (string) $id;
1084
+        if ($userId != null) $parameters['user_id'] = (string) $userId;
1085
+        if ($screenName != null) $parameters['screen_name'] = (string) $screenName;
1086 1086
 
1087 1087
         // make the call
1088
-        return (array)$this->doCall('users/show.json', $parameters);
1088
+        return (array) $this->doCall('users/show.json', $parameters);
1089 1089
     }
1090 1090
 
1091 1091
     /**
@@ -1103,8 +1103,8 @@  discard block
 block discarded – undo
1103 1103
     public function usersLookup($userIds = null, $screenNames = null)
1104 1104
     {
1105 1105
         // redefine
1106
-        $userIds     = (array)$userIds;
1107
-        $screenNames = (array)$screenNames;
1106
+        $userIds     = (array) $userIds;
1107
+        $screenNames = (array) $screenNames;
1108 1108
 
1109 1109
         // validate
1110 1110
         if (empty($userIds) && empty($screenNames)) throw new TwitterException('Specify an userId or a screenName.');
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
         if (!empty($screenNames)) $parameters['screen_name'] = implode(',', $screenNames);
1115 1115
 
1116 1116
         // make the call
1117
-        return (array)$this->doCall('users/lookup.json', $parameters, true);
1117
+        return (array) $this->doCall('users/lookup.json', $parameters, true);
1118 1118
 
1119 1119
     }
1120 1120
 
@@ -1130,12 +1130,12 @@  discard block
 block discarded – undo
1130 1130
     public function usersSearch($q, $perPage = null, $page = null)
1131 1131
     {
1132 1132
         // build parameters
1133
-        $parameters['q'] = (string)$q;
1134
-        if ($perPage != null) $parameters['per_page'] = (int)$perPage;
1135
-        if ($page != null) $parameters['page'] = (int)$page;
1133
+        $parameters['q'] = (string) $q;
1134
+        if ($perPage != null) $parameters['per_page'] = (int) $perPage;
1135
+        if ($page != null) $parameters['page'] = (int) $page;
1136 1136
 
1137 1137
         // make the call
1138
-        return (array)$this->doCall('users/search.json', $parameters, true);
1138
+        return (array) $this->doCall('users/search.json', $parameters, true);
1139 1139
 
1140 1140
     }
1141 1141
 
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
      */
1147 1147
     public function usersSuggestions()
1148 1148
     {
1149
-        return (array)$this->doCall('users/suggestions.json', null, true);
1149
+        return (array) $this->doCall('users/suggestions.json', null, true);
1150 1150
     }
1151 1151
 
1152 1152
     /**
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
      */
1159 1159
     public function usersSuggestionsSlug($slug)
1160 1160
     {
1161
-        return (array)$this->doCall('users/suggestions/' . (string)$slug . '.json');
1161
+        return (array) $this->doCall('users/suggestions/'.(string) $slug.'.json');
1162 1162
     }
1163 1163
 
1164 1164
     /**
@@ -1179,13 +1179,13 @@  discard block
 block discarded – undo
1179 1179
     {
1180 1180
         // build parameters
1181 1181
         $parameters = array();
1182
-        if ($id != null) $parameters['id'] = (string)$id;
1183
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1184
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1185
-        if ($cursor != null) $parameters['cursor'] = (int)$cursor;
1182
+        if ($id != null) $parameters['id'] = (string) $id;
1183
+        if ($userId != null) $parameters['user_id'] = (string) $userId;
1184
+        if ($screenName != null) $parameters['screen_name'] = (string) $screenName;
1185
+        if ($cursor != null) $parameters['cursor'] = (int) $cursor;
1186 1186
 
1187 1187
         // make the call
1188
-        return (array)$this->doCall('statuses/friends.json', $parameters);
1188
+        return (array) $this->doCall('statuses/friends.json', $parameters);
1189 1189
     }
1190 1190
 
1191 1191
     /**
@@ -1202,13 +1202,13 @@  discard block
 block discarded – undo
1202 1202
     {
1203 1203
         // build parameters
1204 1204
         $parameters = array();
1205
-        if ($id != null) $parameters['id'] = (string)$id;
1206
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1207
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1208
-        if ($cursor != null) $parameters['cursor'] = (int)$cursor;
1205
+        if ($id != null) $parameters['id'] = (string) $id;
1206
+        if ($userId != null) $parameters['user_id'] = (string) $userId;
1207
+        if ($screenName != null) $parameters['screen_name'] = (string) $screenName;
1208
+        if ($cursor != null) $parameters['cursor'] = (int) $cursor;
1209 1209
 
1210 1210
         // make the call
1211
-        return (array)$this->doCall('statuses/followers.json', $parameters);
1211
+        return (array) $this->doCall('statuses/followers.json', $parameters);
1212 1212
     }
1213 1213
 
1214 1214
 
@@ -1221,7 +1221,7 @@  discard block
 block discarded – undo
1221 1221
      */
1222 1222
     public function trends()
1223 1223
     {
1224
-        return (array)$this->doCall('trends.json');
1224
+        return (array) $this->doCall('trends.json');
1225 1225
     }
1226 1226
 
1227 1227
     /**
@@ -1235,10 +1235,10 @@  discard block
 block discarded – undo
1235 1235
     {
1236 1236
         // build parameters
1237 1237
         $parameters = array();
1238
-        if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1238
+        if ($exclude != null) $parameters['exclude'] = (string) $exclude;
1239 1239
 
1240 1240
         // make the call
1241
-        return (array)$this->doCall('trends/current.json', $parameters);
1241
+        return (array) $this->doCall('trends/current.json', $parameters);
1242 1242
     }
1243 1243
 
1244 1244
     /**
@@ -1252,11 +1252,11 @@  discard block
 block discarded – undo
1252 1252
     {
1253 1253
         // build parameters
1254 1254
         $parameters = array();
1255
-        if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1256
-        if ($date != null) $parameters['date'] = (string)$date;
1255
+        if ($exclude != null) $parameters['exclude'] = (string) $exclude;
1256
+        if ($date != null) $parameters['date'] = (string) $date;
1257 1257
 
1258 1258
         // make the call
1259
-        return (array)$this->doCall('trends/daily.json', $parameters);
1259
+        return (array) $this->doCall('trends/daily.json', $parameters);
1260 1260
     }
1261 1261
 
1262 1262
     /**
@@ -1270,11 +1270,11 @@  discard block
 block discarded – undo
1270 1270
     {
1271 1271
         // build parameters
1272 1272
         $parameters = array();
1273
-        if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1274
-        if ($date != null) $parameters['date'] = (string)$date;
1273
+        if ($exclude != null) $parameters['exclude'] = (string) $exclude;
1274
+        if ($date != null) $parameters['date'] = (string) $date;
1275 1275
 
1276 1276
         // make the call
1277
-        return (array)$this->doCall('trends/weekly.json', $parameters);
1277
+        return (array) $this->doCall('trends/weekly.json', $parameters);
1278 1278
     }
1279 1279
 
1280 1280
 
@@ -1298,15 +1298,15 @@  discard block
 block discarded – undo
1298 1298
         $allowedModes = array('public', 'private');
1299 1299
 
1300 1300
         // validate
1301
-        if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.');
1301
+        if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: '.implode($allowedModes).'.');
1302 1302
 
1303 1303
         // build parameters
1304
-        $parameters['name'] = (string)$name;
1305
-        if ($mode != null) $parameters['mode'] = (string)$mode;
1306
-        if ($description != null) $parameters['description'] = (string)$description;
1304
+        $parameters['name'] = (string) $name;
1305
+        if ($mode != null) $parameters['mode'] = (string) $mode;
1306
+        if ($description != null) $parameters['description'] = (string) $description;
1307 1307
 
1308 1308
         // make the call
1309
-        return (array)$this->doCall((string)$user . '/lists.json', $parameters, true, 'POST');
1309
+        return (array) $this->doCall((string) $user.'/lists.json', $parameters, true, 'POST');
1310 1310
     }
1311 1311
 
1312 1312
     /**
@@ -1319,10 +1319,10 @@  discard block
 block discarded – undo
1319 1319
     public function userLists($user, $cursor = null)
1320 1320
     {
1321 1321
         $parameters = null;
1322
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1322
+        if ($cursor != null) $parameters['cursor'] = (string) $cursor;
1323 1323
 
1324 1324
         // make the call
1325
-        return (array)$this->doCall((string)$user . '/lists.json', $parameters, true);
1325
+        return (array) $this->doCall((string) $user.'/lists.json', $parameters, true);
1326 1326
     }
1327 1327
 
1328 1328
     /**
@@ -1335,7 +1335,7 @@  discard block
 block discarded – undo
1335 1335
     public function userListsId($user, $id)
1336 1336
     {
1337 1337
         // make the call
1338
-        return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '.json', null, true);
1338
+        return (array) $this->doCall((string) $user.'/lists/'.(string) $id.'.json', null, true);
1339 1339
     }
1340 1340
 
1341 1341
     /**
@@ -1359,15 +1359,15 @@  discard block
 block discarded – undo
1359 1359
         $allowedModes = array('public', 'private');
1360 1360
 
1361 1361
         // validate
1362
-        if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.');
1362
+        if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: '.implode($allowedModes).'.');
1363 1363
 
1364 1364
         // build parameters
1365
-        if ($name != null) $parameters['name'] = (string)$name;
1366
-        if ($mode != null) $parameters['mode'] = (string)$mode;
1367
-        if ($description != null) $parameters['description'] = (string)$description;
1365
+        if ($name != null) $parameters['name'] = (string) $name;
1366
+        if ($mode != null) $parameters['mode'] = (string) $mode;
1367
+        if ($description != null) $parameters['description'] = (string) $description;
1368 1368
 
1369 1369
         // make the call
1370
-        return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '.json', $parameters, true, 'POST');
1370
+        return (array) $this->doCall((string) $user.'/lists/'.(string) $id.'.json', $parameters, true, 'POST');
1371 1371
     }
1372 1372
 
1373 1373
     /**
@@ -1394,13 +1394,13 @@  discard block
 block discarded – undo
1394 1394
 
1395 1395
         // build parameters
1396 1396
         $parameters = array();
1397
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1398
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1399
-        if ($count != null) $parameters['per_page'] = (int)$count;
1400
-        if ($page != null) $parameters['page'] = (int)$page;
1397
+        if ($sinceId != null) $parameters['since_id'] = (string) $sinceId;
1398
+        if ($maxId != null) $parameters['max_id'] = (string) $maxId;
1399
+        if ($count != null) $parameters['per_page'] = (int) $count;
1400
+        if ($page != null) $parameters['page'] = (int) $page;
1401 1401
 
1402 1402
         // make the call
1403
-        return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '/statuses.json', $parameters);
1403
+        return (array) $this->doCall((string) $user.'/lists/'.(string) $id.'/statuses.json', $parameters);
1404 1404
     }
1405 1405
 
1406 1406
     /**
@@ -1413,10 +1413,10 @@  discard block
 block discarded – undo
1413 1413
     public function userListsMemberships($user, $cursor = null)
1414 1414
     {
1415 1415
         $parameters = null;
1416
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1416
+        if ($cursor != null) $parameters['cursor'] = (string) $cursor;
1417 1417
 
1418 1418
         // make the call
1419
-        return (array)$this->doCall((string)$user . '/lists/memberships.json', $parameters, true);
1419
+        return (array) $this->doCall((string) $user.'/lists/memberships.json', $parameters, true);
1420 1420
     }
1421 1421
 
1422 1422
     /**
@@ -1429,10 +1429,10 @@  discard block
 block discarded – undo
1429 1429
     public function userListsSubscriptions($user, $cursor = null)
1430 1430
     {
1431 1431
         $parameters = null;
1432
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1432
+        if ($cursor != null) $parameters['cursor'] = (string) $cursor;
1433 1433
 
1434 1434
         // make the call
1435
-        return (array)$this->doCall((string)$user . '/lists/subscriptions.json', $parameters, true);
1435
+        return (array) $this->doCall((string) $user.'/lists/subscriptions.json', $parameters, true);
1436 1436
     }
1437 1437
 
1438 1438
 
@@ -1448,10 +1448,10 @@  discard block
 block discarded – undo
1448 1448
     public function userListMembers($user, $id, $cursor = null)
1449 1449
     {
1450 1450
         $parameters = null;
1451
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1451
+        if ($cursor != null) $parameters['cursor'] = (string) $cursor;
1452 1452
 
1453 1453
         // make the call
1454
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true);
1454
+        return (array) $this->doCall((string) $user.'/'.(string) $id.'/members.json', $parameters, true);
1455 1455
     }
1456 1456
 
1457 1457
     /**
@@ -1465,10 +1465,10 @@  discard block
 block discarded – undo
1465 1465
     public function userListMembersCreate($user, $id, $userId)
1466 1466
     {
1467 1467
         // build parameters
1468
-        $parameters['id'] = (string)$userId;
1468
+        $parameters['id'] = (string) $userId;
1469 1469
 
1470 1470
         // make the call
1471
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true, 'POST');
1471
+        return (array) $this->doCall((string) $user.'/'.(string) $id.'/members.json', $parameters, true, 'POST');
1472 1472
     }
1473 1473
 
1474 1474
     /**
@@ -1482,11 +1482,11 @@  discard block
 block discarded – undo
1482 1482
     public function userListMembersDelete($user, $id, $userId)
1483 1483
     {
1484 1484
         // build parameters
1485
-        $parameters['id']      = (string)$userId;
1485
+        $parameters['id']      = (string) $userId;
1486 1486
         $parameters['_method'] = 'DELETE';
1487 1487
 
1488 1488
         // make the call
1489
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true, 'POST');
1489
+        return (array) $this->doCall((string) $user.'/'.(string) $id.'/members.json', $parameters, true, 'POST');
1490 1490
     }
1491 1491
 
1492 1492
     /**
@@ -1503,7 +1503,7 @@  discard block
 block discarded – undo
1503 1503
     {
1504 1504
         try {
1505 1505
             // make the call
1506
-            return (array)$this->doCall((string)$user . '/' . (string)$id . '/members/' . (string)$userId . '.json', null, true);
1506
+            return (array) $this->doCall((string) $user.'/'.(string) $id.'/members/'.(string) $userId.'.json', null, true);
1507 1507
         } // catch exceptions
1508 1508
         catch (TwitterException $e) {
1509 1509
             if ($e->getMessage() === 'The specified user is not a member of this list') {
@@ -1525,10 +1525,10 @@  discard block
 block discarded – undo
1525 1525
     public function userListSubscribers($user, $id, $cursor = null)
1526 1526
     {
1527 1527
         $parameters = null;
1528
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1528
+        if ($cursor != null) $parameters['cursor'] = (string) $cursor;
1529 1529
 
1530 1530
         // make the call
1531
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', $parameters, true);
1531
+        return (array) $this->doCall((string) $user.'/'.(string) $id.'/subscribers.json', $parameters, true);
1532 1532
     }
1533 1533
 
1534 1534
     /**
@@ -1541,7 +1541,7 @@  discard block
 block discarded – undo
1541 1541
     public function userListSubscribersCreate($user, $id)
1542 1542
     {
1543 1543
         // make the call
1544
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', null, true, 'POST');
1544
+        return (array) $this->doCall((string) $user.'/'.(string) $id.'/subscribers.json', null, true, 'POST');
1545 1545
     }
1546 1546
 
1547 1547
     /**
@@ -1557,7 +1557,7 @@  discard block
 block discarded – undo
1557 1557
         $parameters['_method'] = 'DELETE';
1558 1558
 
1559 1559
         // make the call
1560
-        return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', $parameters, true, 'POST');
1560
+        return (array) $this->doCall((string) $user.'/'.(string) $id.'/subscribers.json', $parameters, true, 'POST');
1561 1561
     }
1562 1562
 
1563 1563
     /**
@@ -1574,7 +1574,7 @@  discard block
 block discarded – undo
1574 1574
     {
1575 1575
         try {
1576 1576
             // make the call
1577
-            return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers/' . (string)$userId . '.json', null, true);
1577
+            return (array) $this->doCall((string) $user.'/'.(string) $id.'/subscribers/'.(string) $userId.'.json', null, true);
1578 1578
         } // catch exceptions
1579 1579
         catch (TwitterException $e) {
1580 1580
             if ($e->getMessage() === 'The specified user is not a subscriber of this list') {
@@ -1608,13 +1608,13 @@  discard block
 block discarded – undo
1608 1608
 
1609 1609
         // build parameters
1610 1610
         $parameters = array();
1611
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1612
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1613
-        if ($count != null) $parameters['count'] = (int)$count;
1614
-        if ($page != null) $parameters['page'] = (int)$page;
1611
+        if ($sinceId != null) $parameters['since_id'] = (string) $sinceId;
1612
+        if ($maxId != null) $parameters['max_id'] = (string) $maxId;
1613
+        if ($count != null) $parameters['count'] = (int) $count;
1614
+        if ($page != null) $parameters['page'] = (int) $page;
1615 1615
 
1616 1616
         // make the call
1617
-        return (array)$this->doCall('direct_messages.json', $parameters, true);
1617
+        return (array) $this->doCall('direct_messages.json', $parameters, true);
1618 1618
     }
1619 1619
 
1620 1620
     /**
@@ -1639,13 +1639,13 @@  discard block
 block discarded – undo
1639 1639
 
1640 1640
         // build parameters
1641 1641
         $parameters = array();
1642
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1643
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1644
-        if ($count != null) $parameters['count'] = (int)$count;
1645
-        if ($page != null) $parameters['page'] = (int)$page;
1642
+        if ($sinceId != null) $parameters['since_id'] = (string) $sinceId;
1643
+        if ($maxId != null) $parameters['max_id'] = (string) $maxId;
1644
+        if ($count != null) $parameters['count'] = (int) $count;
1645
+        if ($page != null) $parameters['page'] = (int) $page;
1646 1646
 
1647 1647
         // make the call
1648
-        return (array)$this->doCall('direct_messages/sent.json', $parameters, true);
1648
+        return (array) $this->doCall('direct_messages/sent.json', $parameters, true);
1649 1649
     }
1650 1650
 
1651 1651
     /**
@@ -1669,13 +1669,13 @@  discard block
 block discarded – undo
1669 1669
         if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1670 1670
 
1671 1671
         // build parameters
1672
-        $parameters['text'] = (string)$text;
1673
-        if ($id != null) $parameters['user'] = (string)$id;
1674
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1675
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1672
+        $parameters['text'] = (string) $text;
1673
+        if ($id != null) $parameters['user'] = (string) $id;
1674
+        if ($userId != null) $parameters['user_id'] = (string) $userId;
1675
+        if ($screenName != null) $parameters['screen_name'] = (string) $screenName;
1676 1676
 
1677 1677
         // make the call
1678
-        return (array)$this->doCall('direct_messages/new.json', $parameters, true, 'POST');
1678
+        return (array) $this->doCall('direct_messages/new.json', $parameters, true, 'POST');
1679 1679
     }
1680 1680
 
1681 1681
     /**
@@ -1687,10 +1687,10 @@  discard block
 block discarded – undo
1687 1687
     public function directMessagesDestroy($id)
1688 1688
     {
1689 1689
         // build parameters
1690
-        $parameters['id'] = (string)$id;
1690
+        $parameters['id'] = (string) $id;
1691 1691
 
1692 1692
         // make the call
1693
-        return (array)$this->doCall('direct_messages/destroy.json', $parameters, true, 'POST');
1693
+        return (array) $this->doCall('direct_messages/destroy.json', $parameters, true, 'POST');
1694 1694
     }
1695 1695
 
1696 1696
 
@@ -1718,13 +1718,13 @@  discard block
 block discarded – undo
1718 1718
         if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1719 1719
 
1720 1720
         // build parameters
1721
-        if ($id != null) $parameters['id'] = (string)$id;
1722
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1723
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1721
+        if ($id != null) $parameters['id'] = (string) $id;
1722
+        if ($userId != null) $parameters['user_id'] = (string) $userId;
1723
+        if ($screenName != null) $parameters['screen_name'] = (string) $screenName;
1724 1724
         $parameters['follow'] = $follow ? 'true' : 'false';
1725 1725
 
1726 1726
         // make the call
1727
-        return (array)$this->doCall('friendships/create.json', $parameters, true, 'POST');
1727
+        return (array) $this->doCall('friendships/create.json', $parameters, true, 'POST');
1728 1728
     }
1729 1729
 
1730 1730
     /**
@@ -1747,12 +1747,12 @@  discard block
 block discarded – undo
1747 1747
         if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1748 1748
 
1749 1749
         // build parameters
1750
-        if ($id != null) $parameters['id'] = (string)$id;
1751
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1752
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1750
+        if ($id != null) $parameters['id'] = (string) $id;
1751
+        if ($userId != null) $parameters['user_id'] = (string) $userId;
1752
+        if ($screenName != null) $parameters['screen_name'] = (string) $screenName;
1753 1753
 
1754 1754
         // make the call
1755
-        return (array)$this->doCall('friendships/destroy.json', $parameters, true, 'POST');
1755
+        return (array) $this->doCall('friendships/destroy.json', $parameters, true, 'POST');
1756 1756
     }
1757 1757
 
1758 1758
     /**
@@ -1765,11 +1765,11 @@  discard block
 block discarded – undo
1765 1765
     public function friendshipsExists($userA, $userB)
1766 1766
     {
1767 1767
         // build parameters
1768
-        $parameters['user_a'] = (string)$userA;
1769
-        $parameters['user_b'] = (string)$userB;
1768
+        $parameters['user_a'] = (string) $userA;
1769
+        $parameters['user_b'] = (string) $userB;
1770 1770
 
1771 1771
         // make the call
1772
-        return (bool)$this->doCall('friendships/exists.json', $parameters);
1772
+        return (bool) $this->doCall('friendships/exists.json', $parameters);
1773 1773
     }
1774 1774
 
1775 1775
     /**
@@ -1794,13 +1794,13 @@  discard block
 block discarded – undo
1794 1794
         if ($targetId == '' && $targetScreenName == '') throw new TwitterException('Specify an targetId or a targetScreenName.');
1795 1795
 
1796 1796
         // build parameters
1797
-        if ($sourceId != null) $parameters['source_id'] = (string)$sourceId;
1798
-        if ($sourceScreenName != null) $parameters['source_screen_name'] = (string)$sourceScreenName;
1799
-        if ($targetId != null) $parameters['target_id'] = (string)$targetId;
1800
-        if ($targetScreenName != null) $parameters['target_screen_name'] = (string)$targetScreenName;
1797
+        if ($sourceId != null) $parameters['source_id'] = (string) $sourceId;
1798
+        if ($sourceScreenName != null) $parameters['source_screen_name'] = (string) $sourceScreenName;
1799
+        if ($targetId != null) $parameters['target_id'] = (string) $targetId;
1800
+        if ($targetScreenName != null) $parameters['target_screen_name'] = (string) $targetScreenName;
1801 1801
 
1802 1802
         // make the call
1803
-        return (array)$this->doCall('friendships/show.json', $parameters);
1803
+        return (array) $this->doCall('friendships/show.json', $parameters);
1804 1804
     }
1805 1805
 
1806 1806
     /**
@@ -1812,10 +1812,10 @@  discard block
 block discarded – undo
1812 1812
     public function friendshipsIncoming($cursor = null)
1813 1813
     {
1814 1814
         $parameters = null;
1815
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1815
+        if ($cursor != null) $parameters['cursor'] = (string) $cursor;
1816 1816
 
1817 1817
         // make the call
1818
-        return (array)$this->doCall('friendships/incoming.json', $parameters, true);
1818
+        return (array) $this->doCall('friendships/incoming.json', $parameters, true);
1819 1819
     }
1820 1820
 
1821 1821
     /**
@@ -1827,10 +1827,10 @@  discard block
 block discarded – undo
1827 1827
     public function friendshipsOutgoing($cursor = null)
1828 1828
     {
1829 1829
         $parameters = null;
1830
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1830
+        if ($cursor != null) $parameters['cursor'] = (string) $cursor;
1831 1831
 
1832 1832
         // make the call
1833
-        return (array)$this->doCall('friendships/outgoing.json', $parameters, true);
1833
+        return (array) $this->doCall('friendships/outgoing.json', $parameters, true);
1834 1834
     }
1835 1835
 
1836 1836
 
@@ -1856,13 +1856,13 @@  discard block
 block discarded – undo
1856 1856
         if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1857 1857
 
1858 1858
         // build parameters
1859
-        if ($id != null) $parameters['id'] = (string)$id;
1860
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1861
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1862
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1859
+        if ($id != null) $parameters['id'] = (string) $id;
1860
+        if ($userId != null) $parameters['user_id'] = (string) $userId;
1861
+        if ($screenName != null) $parameters['screen_name'] = (string) $screenName;
1862
+        if ($cursor != null) $parameters['cursor'] = (string) $cursor;
1863 1863
 
1864 1864
         // make the call
1865
-        return (array)$this->doCall('friends/ids.json', $parameters);
1865
+        return (array) $this->doCall('friends/ids.json', $parameters);
1866 1866
     }
1867 1867
 
1868 1868
     /**
@@ -1886,13 +1886,13 @@  discard block
 block discarded – undo
1886 1886
         if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1887 1887
 
1888 1888
         // build parameters
1889
-        if ($id != null) $parameters['id'] = (string)$id;
1890
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1891
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1892
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1889
+        if ($id != null) $parameters['id'] = (string) $id;
1890
+        if ($userId != null) $parameters['user_id'] = (string) $userId;
1891
+        if ($screenName != null) $parameters['screen_name'] = (string) $screenName;
1892
+        if ($cursor != null) $parameters['cursor'] = (string) $cursor;
1893 1893
 
1894 1894
         // make the call
1895
-        return (array)$this->doCall('followers/ids.json', $parameters);
1895
+        return (array) $this->doCall('followers/ids.json', $parameters);
1896 1896
     }
1897 1897
 
1898 1898
 
@@ -1905,7 +1905,7 @@  discard block
 block discarded – undo
1905 1905
     public function accountVerifyCredentials()
1906 1906
     {
1907 1907
         // make the call
1908
-        return (array)$this->doCall('account/verify_credentials.json', null, true);
1908
+        return (array) $this->doCall('account/verify_credentials.json', null, true);
1909 1909
     }
1910 1910
 
1911 1911
     /**
@@ -1915,7 +1915,7 @@  discard block
 block discarded – undo
1915 1915
     public function accountRateLimitStatus()
1916 1916
     {
1917 1917
         // make the call
1918
-        return (array)$this->doCall('account/rate_limit_status.json', null);
1918
+        return (array) $this->doCall('account/rate_limit_status.json', null);
1919 1919
     }
1920 1920
 
1921 1921
     /**
@@ -1945,10 +1945,10 @@  discard block
 block discarded – undo
1945 1945
     public function accountUpdateDeliveryDevices($device)
1946 1946
     {
1947 1947
         // build parameters
1948
-        $parameters['device'] = (string)$device;
1948
+        $parameters['device'] = (string) $device;
1949 1949
 
1950 1950
         // make the call
1951
-        return (array)$this->doCall('account/update_delivery_device.json', $parameters, true, 'POST');
1951
+        return (array) $this->doCall('account/update_delivery_device.json', $parameters, true, 'POST');
1952 1952
     }
1953 1953
 
1954 1954
     /**
@@ -1977,14 +1977,14 @@  discard block
 block discarded – undo
1977 1977
         ) throw new TwitterException('Specify a profileBackgroundColor, profileTextColor, profileLinkColor, profileSidebarFillColor or a profileSidebarBorderColor.');
1978 1978
 
1979 1979
         // build parameters
1980
-        if ($profileBackgroundColor != null) $parameters['profile_background_color'] = (string)$profileBackgroundColor;
1981
-        if ($profileTextColor != null) $parameters['profile_text_color'] = (string)$profileTextColor;
1982
-        if ($profileLinkColor != null) $parameters['profile_link_color'] = (string)$profileLinkColor;
1983
-        if ($profileSidebarFillColor != null) $parameters['profile_sidebar_fill_color'] = (string)$profileSidebarFillColor;
1984
-        if ($profileSidebarBorderColor != null) $parameters['profile_sidebar_border_color'] = (string)$profileSidebarBorderColor;
1980
+        if ($profileBackgroundColor != null) $parameters['profile_background_color'] = (string) $profileBackgroundColor;
1981
+        if ($profileTextColor != null) $parameters['profile_text_color'] = (string) $profileTextColor;
1982
+        if ($profileLinkColor != null) $parameters['profile_link_color'] = (string) $profileLinkColor;
1983
+        if ($profileSidebarFillColor != null) $parameters['profile_sidebar_fill_color'] = (string) $profileSidebarFillColor;
1984
+        if ($profileSidebarBorderColor != null) $parameters['profile_sidebar_border_color'] = (string) $profileSidebarBorderColor;
1985 1985
 
1986 1986
         // make the call
1987
-        return (array)$this->doCall('account/update_profile_colors.json', $parameters, true, 'POST');
1987
+        return (array) $this->doCall('account/update_profile_colors.json', $parameters, true, 'POST');
1988 1988
     }
1989 1989
 
1990 1990
     /**
@@ -2000,10 +2000,10 @@  discard block
 block discarded – undo
2000 2000
         throw new TwitterException('Not implemented');
2001 2001
 
2002 2002
         // validate
2003
-        if (!file_exists($image)) throw new TwitterException('Image (' . $image . ') doesn\'t exists.');
2003
+        if (!file_exists($image)) throw new TwitterException('Image ('.$image.') doesn\'t exists.');
2004 2004
 
2005 2005
         // make the call
2006
-        return (array)$this->doCall('account/update_profile_image.json', null, true, 'POST', $image);
2006
+        return (array) $this->doCall('account/update_profile_image.json', null, true, 'POST', $image);
2007 2007
     }
2008 2008
 
2009 2009
     /**
@@ -2020,13 +2020,13 @@  discard block
 block discarded – undo
2020 2020
         throw new TwitterException('Not implemented');
2021 2021
 
2022 2022
         // validate
2023
-        if (!file_exists($image)) throw new TwitterException('Image (' . $image . ') doesn\'t exists.');
2023
+        if (!file_exists($image)) throw new TwitterException('Image ('.$image.') doesn\'t exists.');
2024 2024
 
2025 2025
         // build parameters
2026 2026
         if ($tile) $parameters['tile'] = 'true';
2027 2027
 
2028 2028
         // make the call
2029
-        return (array)$this->doCall('account/update_profile_background_image.json', $parameters, true, 'POST', $image);
2029
+        return (array) $this->doCall('account/update_profile_background_image.json', $parameters, true, 'POST', $image);
2030 2030
     }
2031 2031
 
2032 2032
     /**
@@ -2042,13 +2042,13 @@  discard block
 block discarded – undo
2042 2042
     {
2043 2043
         // build parameters
2044 2044
         $parameters = null;
2045
-        if ($name != null) $parameters['name'] = (string)$name;
2046
-        if ($url != null) $parameters['url'] = (string)$url;
2047
-        if ($location != null) $parameters['location'] = (string)$location;
2048
-        if ($description != null) $parameters['description'] = (string)$description;
2045
+        if ($name != null) $parameters['name'] = (string) $name;
2046
+        if ($url != null) $parameters['url'] = (string) $url;
2047
+        if ($location != null) $parameters['location'] = (string) $location;
2048
+        if ($description != null) $parameters['description'] = (string) $description;
2049 2049
 
2050 2050
         // make the call
2051
-        return (array)$this->doCall('account/update_profile.json', $parameters, true, 'POST');
2051
+        return (array) $this->doCall('account/update_profile.json', $parameters, true, 'POST');
2052 2052
     }
2053 2053
 
2054 2054
 
@@ -2064,11 +2064,11 @@  discard block
 block discarded – undo
2064 2064
     {
2065 2065
         // build parameters
2066 2066
         $parameters = null;
2067
-        if ($id != null) $parameters['id'] = (string)$id;
2068
-        if ($page != null) $parameters['page'] = (int)$page;
2067
+        if ($id != null) $parameters['id'] = (string) $id;
2068
+        if ($page != null) $parameters['page'] = (int) $page;
2069 2069
 
2070 2070
         // make the call
2071
-        return (array)$this->doCall('favorites.json', $parameters, true);
2071
+        return (array) $this->doCall('favorites.json', $parameters, true);
2072 2072
     }
2073 2073
 
2074 2074
     /**
@@ -2080,7 +2080,7 @@  discard block
 block discarded – undo
2080 2080
     public function favoritesCreate($id)
2081 2081
     {
2082 2082
         // make the call
2083
-        return (array)$this->doCall('favorites/create/' . $id . '.json', null, true, 'POST');
2083
+        return (array) $this->doCall('favorites/create/'.$id.'.json', null, true, 'POST');
2084 2084
     }
2085 2085
 
2086 2086
     /**
@@ -2092,7 +2092,7 @@  discard block
 block discarded – undo
2092 2092
     public function favoritesDestroy($id)
2093 2093
     {
2094 2094
         // make the call
2095
-        return (array)$this->doCall('favorites/destroy/' . $id . '.json', null, true, 'POST');
2095
+        return (array) $this->doCall('favorites/destroy/'.$id.'.json', null, true, 'POST');
2096 2096
     }
2097 2097
 
2098 2098
 
@@ -2116,12 +2116,12 @@  discard block
 block discarded – undo
2116 2116
         if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2117 2117
 
2118 2118
         // build parameters
2119
-        if ($id != null) $parameters['id'] = (string)$id;
2120
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2121
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2119
+        if ($id != null) $parameters['id'] = (string) $id;
2120
+        if ($userId != null) $parameters['user_id'] = (string) $userId;
2121
+        if ($screenName != null) $parameters['screen_name'] = (string) $screenName;
2122 2122
 
2123 2123
         // make the call
2124
-        return (array)$this->doCall('notifications/follow.json', $parameters, true, 'POST');
2124
+        return (array) $this->doCall('notifications/follow.json', $parameters, true, 'POST');
2125 2125
     }
2126 2126
 
2127 2127
     /**
@@ -2143,12 +2143,12 @@  discard block
 block discarded – undo
2143 2143
         if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2144 2144
 
2145 2145
         // build parameters
2146
-        if ($id != null) $parameters['id'] = (string)$id;
2147
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2148
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2146
+        if ($id != null) $parameters['id'] = (string) $id;
2147
+        if ($userId != null) $parameters['user_id'] = (string) $userId;
2148
+        if ($screenName != null) $parameters['screen_name'] = (string) $screenName;
2149 2149
 
2150 2150
         // make the call
2151
-        return (array)$this->doCall('notifications/leave.json', $parameters, true, 'POST');
2151
+        return (array) $this->doCall('notifications/leave.json', $parameters, true, 'POST');
2152 2152
     }
2153 2153
 
2154 2154
 
@@ -2172,12 +2172,12 @@  discard block
 block discarded – undo
2172 2172
         if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2173 2173
 
2174 2174
         // build parameters
2175
-        if ($id != null) $parameters['id'] = (string)$id;
2176
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2177
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2175
+        if ($id != null) $parameters['id'] = (string) $id;
2176
+        if ($userId != null) $parameters['user_id'] = (string) $userId;
2177
+        if ($screenName != null) $parameters['screen_name'] = (string) $screenName;
2178 2178
 
2179 2179
         // make the call
2180
-        return (array)$this->doCall('blocks/create.json', $parameters, true, 'POST');
2180
+        return (array) $this->doCall('blocks/create.json', $parameters, true, 'POST');
2181 2181
     }
2182 2182
 
2183 2183
     /**
@@ -2199,12 +2199,12 @@  discard block
 block discarded – undo
2199 2199
         if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2200 2200
 
2201 2201
         // build parameters
2202
-        if ($id != null) $parameters['id'] = (string)$id;
2203
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2204
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2202
+        if ($id != null) $parameters['id'] = (string) $id;
2203
+        if ($userId != null) $parameters['user_id'] = (string) $userId;
2204
+        if ($screenName != null) $parameters['screen_name'] = (string) $screenName;
2205 2205
 
2206 2206
         // make the call
2207
-        return (array)$this->doCall('blocks/destroy.json', $parameters, true, 'POST');
2207
+        return (array) $this->doCall('blocks/destroy.json', $parameters, true, 'POST');
2208 2208
     }
2209 2209
 
2210 2210
     /**
@@ -2226,13 +2226,13 @@  discard block
 block discarded – undo
2226 2226
         if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2227 2227
 
2228 2228
         // build parameters
2229
-        if ($id != null) $parameters['id'] = (string)$id;
2230
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2231
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2229
+        if ($id != null) $parameters['id'] = (string) $id;
2230
+        if ($userId != null) $parameters['user_id'] = (string) $userId;
2231
+        if ($screenName != null) $parameters['screen_name'] = (string) $screenName;
2232 2232
 
2233 2233
         try {
2234 2234
             // make the call
2235
-            return (array)$this->doCall('blocks/exists.json', $parameters, true);
2235
+            return (array) $this->doCall('blocks/exists.json', $parameters, true);
2236 2236
         } // catch exceptions
2237 2237
         catch (TwitterException $e) {
2238 2238
             if ($e->getMessage() === 'You are not blocking this user.') {
@@ -2251,10 +2251,10 @@  discard block
 block discarded – undo
2251 2251
     {
2252 2252
         // build parameters
2253 2253
         $parameters = null;
2254
-        if ($page != null) $parameters['page'] = (int)$page;
2254
+        if ($page != null) $parameters['page'] = (int) $page;
2255 2255
 
2256 2256
         // make the call
2257
-        return (array)$this->doCall('blocks/blocking.json', $parameters, true);
2257
+        return (array) $this->doCall('blocks/blocking.json', $parameters, true);
2258 2258
     }
2259 2259
 
2260 2260
     /**
@@ -2265,7 +2265,7 @@  discard block
 block discarded – undo
2265 2265
     public function blocksBlockingIds()
2266 2266
     {
2267 2267
         // make the call
2268
-        return (array)$this->doCall('blocks/blocking/ids.json', null, true);
2268
+        return (array) $this->doCall('blocks/blocking/ids.json', null, true);
2269 2269
     }
2270 2270
 
2271 2271
 
@@ -2289,12 +2289,12 @@  discard block
 block discarded – undo
2289 2289
         if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2290 2290
 
2291 2291
         // build parameters
2292
-        if ($id != null) $parameters['id'] = (string)$id;
2293
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2294
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2292
+        if ($id != null) $parameters['id'] = (string) $id;
2293
+        if ($userId != null) $parameters['user_id'] = (string) $userId;
2294
+        if ($screenName != null) $parameters['screen_name'] = (string) $screenName;
2295 2295
 
2296 2296
         // make the call
2297
-        return (array)$this->doCall('report_spam.json', $parameters, true, 'POST');
2297
+        return (array) $this->doCall('report_spam.json', $parameters, true, 'POST');
2298 2298
     }
2299 2299
 
2300 2300
 
@@ -2307,7 +2307,7 @@  discard block
 block discarded – undo
2307 2307
     public function savedSearches()
2308 2308
     {
2309 2309
         // make the call
2310
-        return (array)$this->doCall('saved_searches.json', null, true);
2310
+        return (array) $this->doCall('saved_searches.json', null, true);
2311 2311
     }
2312 2312
 
2313 2313
     /**
@@ -2319,10 +2319,10 @@  discard block
 block discarded – undo
2319 2319
     public function savedSearchesShow($id)
2320 2320
     {
2321 2321
         // build parameters
2322
-        $parameters['id'] = (string)$id;
2322
+        $parameters['id'] = (string) $id;
2323 2323
 
2324 2324
         // make the call
2325
-        return (array)$this->doCall('saved_searches/show.json', $parameters, true);
2325
+        return (array) $this->doCall('saved_searches/show.json', $parameters, true);
2326 2326
     }
2327 2327
 
2328 2328
     /**
@@ -2334,10 +2334,10 @@  discard block
 block discarded – undo
2334 2334
     public function savedSearchesCreate($query)
2335 2335
     {
2336 2336
         // build parameters
2337
-        $parameters['query'] = (string)$query;
2337
+        $parameters['query'] = (string) $query;
2338 2338
 
2339 2339
         // make the call
2340
-        return (array)$this->doCall('saved_searches/create.json', $parameters, true, 'POST');
2340
+        return (array) $this->doCall('saved_searches/create.json', $parameters, true, 'POST');
2341 2341
     }
2342 2342
 
2343 2343
     /**
@@ -2349,7 +2349,7 @@  discard block
 block discarded – undo
2349 2349
      */
2350 2350
     public function savedSearchesDestroy($id)
2351 2351
     {
2352
-        return (array)$this->doCall('saved_searches/destroy/' . (string)$id . '.json', null, true, 'POST');
2352
+        return (array) $this->doCall('saved_searches/destroy/'.(string) $id.'.json', null, true, 'POST');
2353 2353
     }
2354 2354
 
2355 2355
 
@@ -2369,7 +2369,7 @@  discard block
 block discarded – undo
2369 2369
         $parameters = array();
2370 2370
 
2371 2371
         // set callback
2372
-        if ($callbackURL != null) $parameters['oauth_callback'] = (string)$callbackURL;
2372
+        if ($callbackURL != null) $parameters['oauth_callback'] = (string) $callbackURL;
2373 2373
 
2374 2374
         // make the call
2375 2375
         $response = $this->doOAuthCall('request_token', $parameters);
@@ -2397,8 +2397,8 @@  discard block
 block discarded – undo
2397 2397
     {
2398 2398
         // init var
2399 2399
         $parameters                   = array();
2400
-        $parameters['oauth_token']    = (string)$token;
2401
-        $parameters['oauth_verifier'] = (string)$verifier;
2400
+        $parameters['oauth_token']    = (string) $token;
2401
+        $parameters['oauth_verifier'] = (string) $verifier;
2402 2402
 
2403 2403
         // make the call
2404 2404
         $response = $this->doOAuthCall('access_token', $parameters);
@@ -2418,7 +2418,7 @@  discard block
 block discarded – undo
2418 2418
      */
2419 2419
     public function oAuthAuthorize()
2420 2420
     {
2421
-        header('Location: ' . self::SECURE_API_URL . '/oauth/authorize?oauth_token=' . $this->oAuthToken);
2421
+        header('Location: '.self::SECURE_API_URL.'/oauth/authorize?oauth_token='.$this->oAuthToken);
2422 2422
     }
2423 2423
 
2424 2424
     /**
@@ -2448,11 +2448,11 @@  discard block
 block discarded – undo
2448 2448
     {
2449 2449
         // build parameters
2450 2450
         $parameters = null;
2451
-        if ($lat != null) $parameters['lat_for_trends'] = (float)$lat;
2452
-        if ($long != null) $parameters['long_for_trends'] = (float)$long;
2451
+        if ($lat != null) $parameters['lat_for_trends'] = (float) $lat;
2452
+        if ($long != null) $parameters['long_for_trends'] = (float) $long;
2453 2453
 
2454 2454
         // make the call
2455
-        return (array)$this->doCall('trends/available.json', $parameters);
2455
+        return (array) $this->doCall('trends/available.json', $parameters);
2456 2456
     }
2457 2457
 
2458 2458
     /**
@@ -2467,7 +2467,7 @@  discard block
 block discarded – undo
2467 2467
     public function trendsLocation($woeid)
2468 2468
     {
2469 2469
         // make the call
2470
-        return (array)$this->doCall('trends/location/' . (string)$woeid . '.json');
2470
+        return (array) $this->doCall('trends/location/'.(string) $woeid.'.json');
2471 2471
     }
2472 2472
 
2473 2473
 
@@ -2488,14 +2488,14 @@  discard block
 block discarded – undo
2488 2488
     public function geoReverseGeoCode($lat, $long, $accuracy = null, $granularity = null, $maxResults = null)
2489 2489
     {
2490 2490
         // build parameters
2491
-        $parameters['lat']  = (float)$lat;
2492
-        $parameters['long'] = (float)$long;
2493
-        if ($accuracy != null) $parameters['accuracy'] = (string)$accuracy;
2494
-        if ($granularity != null) $parameters['granularity'] = (string)$granularity;
2495
-        if ($maxResults != null) $parameters['max_results'] = (int)$maxResults;
2491
+        $parameters['lat']  = (float) $lat;
2492
+        $parameters['long'] = (float) $long;
2493
+        if ($accuracy != null) $parameters['accuracy'] = (string) $accuracy;
2494
+        if ($granularity != null) $parameters['granularity'] = (string) $granularity;
2495
+        if ($maxResults != null) $parameters['max_results'] = (int) $maxResults;
2496 2496
 
2497 2497
         // make the call
2498
-        return (array)$this->doCall('geo/reverse_geocode.json', $parameters);
2498
+        return (array) $this->doCall('geo/reverse_geocode.json', $parameters);
2499 2499
     }
2500 2500
 
2501 2501
     /**
@@ -2509,10 +2509,10 @@  discard block
 block discarded – undo
2509 2509
     {
2510 2510
         // build parameters
2511 2511
         $parameters = null;
2512
-        if ($placeId != null) $parameters['place_id'] = (string)$placeId;
2512
+        if ($placeId != null) $parameters['place_id'] = (string) $placeId;
2513 2513
 
2514 2514
         // make the call
2515
-        return (array)$this->doCall('geo/id/' . (string)$id . '.json', $parameters);
2515
+        return (array) $this->doCall('geo/id/'.(string) $id.'.json', $parameters);
2516 2516
     }
2517 2517
 
2518 2518
 
Please login to merge, or discard this patch.
Braces   +611 added lines, -204 removed lines patch added patch discarded remove patch
@@ -125,7 +125,9 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function __destruct()
127 127
     {
128
-        if ($this->curl != null) curl_close($this->curl);
128
+        if ($this->curl != null) {
129
+        	curl_close($this->curl);
130
+        }
129 131
     }
130 132
 
131 133
     /**
@@ -137,7 +139,9 @@  discard block
 block discarded – undo
137 139
     private function buildQuery(array $parameters)
138 140
     {
139 141
         // no parameters?
140
-        if (empty($parameters)) return '';
142
+        if (empty($parameters)) {
143
+        	return '';
144
+        }
141 145
 
142 146
         // encode the keys
143 147
         $keys = self::urlencode_rfc3986(array_keys($parameters));
@@ -154,11 +158,15 @@  discard block
 block discarded – undo
154 158
         // loop parameters
155 159
         foreach ($parameters as $key => $value) {
156 160
             // sort by value
157
-            if (is_array($value)) $parameters[$key] = natsort($value);
161
+            if (is_array($value)) {
162
+            	$parameters[$key] = natsort($value);
163
+            }
158 164
         }
159 165
 
160 166
         // process parameters
161
-        foreach ($parameters as $key => $value) $chunks[] = $key . '=' . str_replace('%25', '%', $value);
167
+        foreach ($parameters as $key => $value) {
168
+        	$chunks[] = $key . '=' . str_replace('%25', '%', $value);
169
+        }
162 170
 
163 171
         // return
164 172
         return implode('&', $chunks);
@@ -195,7 +203,9 @@  discard block
 block discarded – undo
195 203
         // loop parameters
196 204
         foreach ($parameters as $key => $value) {
197 205
             // sort by value
198
-            if (is_array($value)) $parameters[$key] = natsort($value);
206
+            if (is_array($value)) {
207
+            	$parameters[$key] = natsort($value);
208
+            }
199 209
         }
200 210
 
201 211
         // process queries
@@ -233,7 +243,9 @@  discard block
 block discarded – undo
233 243
         $chunks = array();
234 244
 
235 245
         // process queries
236
-        foreach ($parameters as $key => $value) $chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key) . '="' . self::urlencode_rfc3986($value) . '"');
246
+        foreach ($parameters as $key => $value) {
247
+        	$chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key) . '="' . self::urlencode_rfc3986($value) . '"');
248
+        }
237 249
 
238 250
         // build return
239 251
         $return = 'Authorization: OAuth realm="' . $parts['scheme'] . '://' . $parts['host'] . $parts['path'] . '", ';
@@ -288,7 +300,9 @@  discard block
 block discarded – undo
288 300
         $options[CURLOPT_POSTFIELDS]     = $this->buildQuery($parameters);
289 301
 
290 302
         // init
291
-        if ($this->curl == null) $this->curl = curl_init();
303
+        if ($this->curl == null) {
304
+        	$this->curl = curl_init();
305
+        }
292 306
 
293 307
         // set options
294 308
         curl_setopt_array($this->curl, $options);
@@ -302,7 +316,9 @@  discard block
 block discarded – undo
302 316
         $errorMessage = curl_error($this->curl);
303 317
 
304 318
         // error?
305
-        if ($errorNumber != '') throw new TwitterException($errorMessage, $errorNumber);
319
+        if ($errorNumber != '') {
320
+        	throw new TwitterException($errorMessage, $errorNumber);
321
+        }
306 322
 
307 323
         // init var
308 324
         $return = array();
@@ -343,7 +359,9 @@  discard block
 block discarded – undo
343 359
         $expectJSON   = (bool)$expectJSON;
344 360
 
345 361
         // validate method
346
-        if (!in_array($method, $allowedMethods)) throw new TwitterException('Unknown method (' . $method . '). Allowed methods are: ' . implode(', ', $allowedMethods));
362
+        if (!in_array($method, $allowedMethods)) {
363
+        	throw new TwitterException('Unknown method (' . $method . '). Allowed methods are: ' . implode(', ', $allowedMethods));
364
+        }
347 365
 
348 366
         // append default parameters
349 367
         $oauth['oauth_consumer_key']     = $this->getConsumerKey();
@@ -355,7 +373,9 @@  discard block
 block discarded – undo
355 373
 
356 374
         // set data
357 375
         $data = $oauth;
358
-        if (!empty($parameters)) $data = array_merge($data, $parameters);
376
+        if (!empty($parameters)) {
377
+        	$data = array_merge($data, $parameters);
378
+        }
359 379
 
360 380
         // calculate the base string
361 381
         $base = $this->calculateBaseString(self::API_URL . '/' . $url, $method, $data);
@@ -380,8 +400,11 @@  discard block
 block discarded – undo
380 400
                 $mimeType = 'application/octet-stream';
381 401
                 if ($fileInfo['extension'] === 'jpg' || $fileInfo['extension'] === 'jpeg') {
382 402
                     $mimeType = 'image/jpeg';
383
-                } elseif ($fileInfo['extension'] === 'gif') $mimeType = 'image/gif';
384
-                elseif ($fileInfo['extension'] === 'png') $mimeType = 'image/png';
403
+                } elseif ($fileInfo['extension'] === 'gif') {
404
+                	$mimeType = 'image/gif';
405
+                } elseif ($fileInfo['extension'] === 'png') {
406
+                	$mimeType = 'image/png';
407
+                }
385 408
 
386 409
                 // init var
387 410
                 $content = '--' . $boundary . "\r\n";
@@ -396,13 +419,17 @@  discard block
 block discarded – undo
396 419
                 // set content
397 420
                 $options[CURLOPT_POSTFIELDS] = $content;
398 421
             } // no file
399
-            else $options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters);
422
+            else {
423
+            	$options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters);
424
+            }
400 425
 
401 426
             // enable post
402 427
             $options[CURLOPT_POST] = 1;
403 428
         } else {
404 429
             // add the parameters into the querystring
405
-            if (!empty($parameters)) $url .= '?' . $this->buildQuery($parameters);
430
+            if (!empty($parameters)) {
431
+            	$url .= '?' . $this->buildQuery($parameters);
432
+            }
406 433
         }
407 434
 
408 435
         // set options
@@ -418,7 +445,9 @@  discard block
 block discarded – undo
418 445
         $options[CURLOPT_HTTPHEADER]     = $headers;
419 446
 
420 447
         // init
421
-        if ($this->curl == null) $this->curl = curl_init();
448
+        if ($this->curl == null) {
449
+        	$this->curl = curl_init();
450
+        }
422 451
 
423 452
         // set options
424 453
         curl_setopt_array($this->curl, $options);
@@ -432,7 +461,9 @@  discard block
 block discarded – undo
432 461
         $errorMessage = curl_error($this->curl);
433 462
 
434 463
         // we don't expext JSON, return the response
435
-        if (!$expectJSON) return $response;
464
+        if (!$expectJSON) {
465
+        	return $response;
466
+        }
436 467
 
437 468
         // replace ids with their string values, added because of some PHP-version can't handle these large values
438 469
         $response = preg_replace('/id":(\d+)/', 'id":"\1"', $response);
@@ -487,7 +518,9 @@  discard block
 block discarded – undo
487 518
             // throw exception
488 519
             if (isset($json['errors'][0]['message'])) {
489 520
                 throw new TwitterException($json['errors'][0]['message']);
490
-            } else throw new TwitterException('Invalid response.');
521
+            } else {
522
+            	throw new TwitterException('Invalid response.');
523
+            }
491 524
         }
492 525
 
493 526
         // any error
@@ -689,7 +722,9 @@  discard block
 block discarded – undo
689 722
 
690 723
         // build parameters
691 724
         $parameters = array();
692
-        if ($skipUser) $parameters['skip_user'] = 'true';
725
+        if ($skipUser) {
726
+        	$parameters['skip_user'] = 'true';
727
+        }
693 728
 
694 729
         // make the call
695 730
         return (array)$this->doCall('statuses/public_timeline.json', $parameters);
@@ -712,11 +747,21 @@  discard block
 block discarded – undo
712 747
 
713 748
         // build parameters
714 749
         $parameters = array();
715
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
716
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
717
-        if ($count != null) $parameters['count'] = (int)$count;
718
-        if ($page != null) $parameters['page'] = (int)$page;
719
-        if ($skipUser) $parameters['skip_user'] = 'true';
750
+        if ($sinceId != null) {
751
+        	$parameters['since_id'] = (string)$sinceId;
752
+        }
753
+        if ($maxId != null) {
754
+        	$parameters['max_id'] = (string)$maxId;
755
+        }
756
+        if ($count != null) {
757
+        	$parameters['count'] = (int)$count;
758
+        }
759
+        if ($page != null) {
760
+        	$parameters['page'] = (int)$page;
761
+        }
762
+        if ($skipUser) {
763
+        	$parameters['skip_user'] = 'true';
764
+        }
720 765
 
721 766
         // make the call
722 767
         return (array)$this->doCall('statuses/home_timeline.json', $parameters, true);
@@ -743,11 +788,21 @@  discard block
 block discarded – undo
743 788
 
744 789
         // build parameters
745 790
         $parameters = array();
746
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
747
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
748
-        if ($count != null) $parameters['count'] = (int)$count;
749
-        if ($page != null) $parameters['page'] = (int)$page;
750
-        if ($skipUser) $parameters['skip_user'] = 'true';
791
+        if ($sinceId != null) {
792
+        	$parameters['since_id'] = (string)$sinceId;
793
+        }
794
+        if ($maxId != null) {
795
+        	$parameters['max_id'] = (string)$maxId;
796
+        }
797
+        if ($count != null) {
798
+        	$parameters['count'] = (int)$count;
799
+        }
800
+        if ($page != null) {
801
+        	$parameters['page'] = (int)$page;
802
+        }
803
+        if ($skipUser) {
804
+        	$parameters['skip_user'] = 'true';
805
+        }
751 806
 
752 807
         // make the call
753 808
         return (array)$this->doCall('statuses/friends_timeline.json', $parameters, true);
@@ -777,14 +832,30 @@  discard block
 block discarded – undo
777 832
 
778 833
         // build parameters
779 834
         $parameters = array();
780
-        if ($id != null) $parameters['id'] = (string)$id;
781
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
782
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
783
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
784
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
785
-        if ($count != null) $parameters['count'] = (int)$count;
786
-        if ($page != null) $parameters['page'] = (int)$page;
787
-        if ($skipUser) $parameters['skip_user'] = 'true';
835
+        if ($id != null) {
836
+        	$parameters['id'] = (string)$id;
837
+        }
838
+        if ($userId != null) {
839
+        	$parameters['user_id'] = (string)$userId;
840
+        }
841
+        if ($screenName != null) {
842
+        	$parameters['screen_name'] = (string)$screenName;
843
+        }
844
+        if ($sinceId != null) {
845
+        	$parameters['since_id'] = (string)$sinceId;
846
+        }
847
+        if ($maxId != null) {
848
+        	$parameters['max_id'] = (string)$maxId;
849
+        }
850
+        if ($count != null) {
851
+        	$parameters['count'] = (int)$count;
852
+        }
853
+        if ($page != null) {
854
+        	$parameters['page'] = (int)$page;
855
+        }
856
+        if ($skipUser) {
857
+        	$parameters['skip_user'] = 'true';
858
+        }
788 859
 
789 860
         // make the call
790 861
         return (array)$this->doCall('statuses/user_timeline.json', $parameters, true);
@@ -808,14 +879,24 @@  discard block
 block discarded – undo
808 879
     public function statusesMentions($sinceId = null, $maxId = null, $count = null, $page = null)
809 880
     {
810 881
         // validate
811
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
882
+        if ($count != null && $count > 200) {
883
+        	throw new TwitterException('Count may not be greater than 200.');
884
+        }
812 885
 
813 886
         // build parameters
814 887
         $parameters = array();
815
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
816
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
817
-        if ($count != null) $parameters['count'] = (int)$count;
818
-        if ($page != null) $parameters['page'] = (int)$page;
888
+        if ($sinceId != null) {
889
+        	$parameters['since_id'] = (string)$sinceId;
890
+        }
891
+        if ($maxId != null) {
892
+        	$parameters['max_id'] = (string)$maxId;
893
+        }
894
+        if ($count != null) {
895
+        	$parameters['count'] = (int)$count;
896
+        }
897
+        if ($page != null) {
898
+        	$parameters['page'] = (int)$page;
899
+        }
819 900
 
820 901
         // make the call
821 902
         return (array)$this->doCall('statuses/mentions.json', $parameters);
@@ -839,14 +920,24 @@  discard block
 block discarded – undo
839 920
     public function statusesRetweetedByMe($sinceId = null, $maxId = null, $count = null, $page = null)
840 921
     {
841 922
         // validate
842
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
923
+        if ($count != null && $count > 200) {
924
+        	throw new TwitterException('Count may not be greater than 200.');
925
+        }
843 926
 
844 927
         // build parameters
845 928
         $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;
929
+        if ($sinceId != null) {
930
+        	$parameters['since_id'] = (string)$sinceId;
931
+        }
932
+        if ($maxId != null) {
933
+        	$parameters['max_id'] = (string)$maxId;
934
+        }
935
+        if ($count != null) {
936
+        	$parameters['count'] = (int)$count;
937
+        }
938
+        if ($page != null) {
939
+        	$parameters['page'] = (int)$page;
940
+        }
850 941
 
851 942
         // make the call
852 943
         return (array)$this->doCall('statuses/retweeted_by_me.json', $parameters);
@@ -870,14 +961,24 @@  discard block
 block discarded – undo
870 961
     public function statusesRetweetedToMe($sinceId = null, $maxId = null, $count = null, $page = null)
871 962
     {
872 963
         // validate
873
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
964
+        if ($count != null && $count > 200) {
965
+        	throw new TwitterException('Count may not be greater than 200.');
966
+        }
874 967
 
875 968
         // build parameters
876 969
         $parameters = array();
877
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
878
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
879
-        if ($count != null) $parameters['count'] = (int)$count;
880
-        if ($page != null) $parameters['page'] = (int)$page;
970
+        if ($sinceId != null) {
971
+        	$parameters['since_id'] = (string)$sinceId;
972
+        }
973
+        if ($maxId != null) {
974
+        	$parameters['max_id'] = (string)$maxId;
975
+        }
976
+        if ($count != null) {
977
+        	$parameters['count'] = (int)$count;
978
+        }
979
+        if ($page != null) {
980
+        	$parameters['page'] = (int)$page;
981
+        }
881 982
 
882 983
         // make the call
883 984
         return (array)$this->doCall('statuses/retweeted_by_me.json', $parameters);
@@ -903,14 +1004,24 @@  discard block
 block discarded – undo
903 1004
     public function statusesReweetsOfMe($sinceId = null, $maxId = null, $count = null, $page = null)
904 1005
     {
905 1006
         // validate
906
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1007
+        if ($count != null && $count > 200) {
1008
+        	throw new TwitterException('Count may not be greater than 200.');
1009
+        }
907 1010
 
908 1011
         // build parameters
909 1012
         $parameters = array();
910
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
911
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
912
-        if ($count != null) $parameters['count'] = (int)$count;
913
-        if ($page != null) $parameters['page'] = (int)$page;
1013
+        if ($sinceId != null) {
1014
+        	$parameters['since_id'] = (string)$sinceId;
1015
+        }
1016
+        if ($maxId != null) {
1017
+        	$parameters['max_id'] = (string)$maxId;
1018
+        }
1019
+        if ($count != null) {
1020
+        	$parameters['count'] = (int)$count;
1021
+        }
1022
+        if ($page != null) {
1023
+        	$parameters['page'] = (int)$page;
1024
+        }
914 1025
 
915 1026
         // make the call
916 1027
         return (array)$this->doCall('statuses/retweets_of_me.json', $parameters);
@@ -946,11 +1057,21 @@  discard block
 block discarded – undo
946 1057
     {
947 1058
         // build parameters
948 1059
         $parameters['status'] = (string)$status;
949
-        if ($inReplyToStatusId != null) $parameters['in_reply_to_status_id'] = (string)$inReplyToStatusId;
950
-        if ($lat != null) $parameters['lat'] = (float)$lat;
951
-        if ($long != null) $parameters['long'] = (float)$long;
952
-        if ($placeId != null) $parameters['place_id'] = (string)$placeId;
953
-        if ($displayCoordinates) $parameters['display_coordinates'] = 'true';
1060
+        if ($inReplyToStatusId != null) {
1061
+        	$parameters['in_reply_to_status_id'] = (string)$inReplyToStatusId;
1062
+        }
1063
+        if ($lat != null) {
1064
+        	$parameters['lat'] = (float)$lat;
1065
+        }
1066
+        if ($long != null) {
1067
+        	$parameters['long'] = (float)$long;
1068
+        }
1069
+        if ($placeId != null) {
1070
+        	$parameters['place_id'] = (string)$placeId;
1071
+        }
1072
+        if ($displayCoordinates) {
1073
+        	$parameters['display_coordinates'] = 'true';
1074
+        }
954 1075
 
955 1076
         // make the call
956 1077
         return (array)$this->doCall('statuses/update.json', $parameters, true, 'POST');
@@ -996,11 +1117,15 @@  discard block
 block discarded – undo
996 1117
     public function statusesRetweets($id, $count = null)
997 1118
     {
998 1119
         // validate
999
-        if ($count != null && $count > 100) throw new TwitterException('Count may not be greater than 100.');
1120
+        if ($count != null && $count > 100) {
1121
+        	throw new TwitterException('Count may not be greater than 100.');
1122
+        }
1000 1123
 
1001 1124
         // build parameters
1002 1125
         $parameters = null;
1003
-        if ($count != null) $parameters['count'] = (int)$count;
1126
+        if ($count != null) {
1127
+        	$parameters['count'] = (int)$count;
1128
+        }
1004 1129
 
1005 1130
         // make the call
1006 1131
         return (array)$this->doCall('statuses/retweets/' . $id . '.json', $parameters);
@@ -1021,12 +1146,18 @@  discard block
 block discarded – undo
1021 1146
     public function statusesIdRetweetedBy($id, $count = null, $page = null)
1022 1147
     {
1023 1148
         // validate
1024
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1149
+        if ($count != null && $count > 200) {
1150
+        	throw new TwitterException('Count may not be greater than 200.');
1151
+        }
1025 1152
 
1026 1153
         // build parameters
1027 1154
         $parameters = null;
1028
-        if ($count != null) $parameters['count'] = (int)$count;
1029
-        if ($page != null) $parameters['page'] = (int)$page;
1155
+        if ($count != null) {
1156
+        	$parameters['count'] = (int)$count;
1157
+        }
1158
+        if ($page != null) {
1159
+        	$parameters['page'] = (int)$page;
1160
+        }
1030 1161
 
1031 1162
         // make the call
1032 1163
         return (array)$this->doCall('statuses/' . (string)$id . '/retweeted_by.json', $parameters, true);
@@ -1047,12 +1178,18 @@  discard block
 block discarded – undo
1047 1178
     public function statusesIdRetweetedByIds($id, $count = null, $page = null)
1048 1179
     {
1049 1180
         // validate
1050
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1181
+        if ($count != null && $count > 200) {
1182
+        	throw new TwitterException('Count may not be greater than 200.');
1183
+        }
1051 1184
 
1052 1185
         // build parameters
1053 1186
         $parameters = null;
1054
-        if ($count != null) $parameters['count'] = (int)$count;
1055
-        if ($page != null) $parameters['page'] = (int)$page;
1187
+        if ($count != null) {
1188
+        	$parameters['count'] = (int)$count;
1189
+        }
1190
+        if ($page != null) {
1191
+        	$parameters['page'] = (int)$page;
1192
+        }
1056 1193
 
1057 1194
         // make the call
1058 1195
         return (array)$this->doCall('statuses/' . (string)$id . '/retweeted_by/ids.json', $parameters, true);
@@ -1077,12 +1214,20 @@  discard block
 block discarded – undo
1077 1214
     public function usersShow($id = null, $userId = null, $screenName = null)
1078 1215
     {
1079 1216
         // validate
1080
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1217
+        if ($id == '' && $userId == '' && $screenName == '') {
1218
+        	throw new TwitterException('Specify an id or an userId or a screenName.');
1219
+        }
1081 1220
 
1082 1221
         // build parameters
1083
-        if ($id != null) $parameters['id'] = (string)$id;
1084
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1085
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1222
+        if ($id != null) {
1223
+        	$parameters['id'] = (string)$id;
1224
+        }
1225
+        if ($userId != null) {
1226
+        	$parameters['user_id'] = (string)$userId;
1227
+        }
1228
+        if ($screenName != null) {
1229
+        	$parameters['screen_name'] = (string)$screenName;
1230
+        }
1086 1231
 
1087 1232
         // make the call
1088 1233
         return (array)$this->doCall('users/show.json', $parameters);
@@ -1107,11 +1252,17 @@  discard block
 block discarded – undo
1107 1252
         $screenNames = (array)$screenNames;
1108 1253
 
1109 1254
         // validate
1110
-        if (empty($userIds) && empty($screenNames)) throw new TwitterException('Specify an userId or a screenName.');
1255
+        if (empty($userIds) && empty($screenNames)) {
1256
+        	throw new TwitterException('Specify an userId or a screenName.');
1257
+        }
1111 1258
 
1112 1259
         // build parameters
1113
-        if (!empty($userIds)) $parameters['user_id'] = implode(',', $userIds);
1114
-        if (!empty($screenNames)) $parameters['screen_name'] = implode(',', $screenNames);
1260
+        if (!empty($userIds)) {
1261
+        	$parameters['user_id'] = implode(',', $userIds);
1262
+        }
1263
+        if (!empty($screenNames)) {
1264
+        	$parameters['screen_name'] = implode(',', $screenNames);
1265
+        }
1115 1266
 
1116 1267
         // make the call
1117 1268
         return (array)$this->doCall('users/lookup.json', $parameters, true);
@@ -1131,8 +1282,12 @@  discard block
 block discarded – undo
1131 1282
     {
1132 1283
         // build parameters
1133 1284
         $parameters['q'] = (string)$q;
1134
-        if ($perPage != null) $parameters['per_page'] = (int)$perPage;
1135
-        if ($page != null) $parameters['page'] = (int)$page;
1285
+        if ($perPage != null) {
1286
+        	$parameters['per_page'] = (int)$perPage;
1287
+        }
1288
+        if ($page != null) {
1289
+        	$parameters['page'] = (int)$page;
1290
+        }
1136 1291
 
1137 1292
         // make the call
1138 1293
         return (array)$this->doCall('users/search.json', $parameters, true);
@@ -1179,10 +1334,18 @@  discard block
 block discarded – undo
1179 1334
     {
1180 1335
         // build parameters
1181 1336
         $parameters = array();
1182
-        if ($id != null) $parameters['id'] = (string)$id;
1183
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1184
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1185
-        if ($cursor != null) $parameters['cursor'] = (int)$cursor;
1337
+        if ($id != null) {
1338
+        	$parameters['id'] = (string)$id;
1339
+        }
1340
+        if ($userId != null) {
1341
+        	$parameters['user_id'] = (string)$userId;
1342
+        }
1343
+        if ($screenName != null) {
1344
+        	$parameters['screen_name'] = (string)$screenName;
1345
+        }
1346
+        if ($cursor != null) {
1347
+        	$parameters['cursor'] = (int)$cursor;
1348
+        }
1186 1349
 
1187 1350
         // make the call
1188 1351
         return (array)$this->doCall('statuses/friends.json', $parameters);
@@ -1202,10 +1365,18 @@  discard block
 block discarded – undo
1202 1365
     {
1203 1366
         // build parameters
1204 1367
         $parameters = array();
1205
-        if ($id != null) $parameters['id'] = (string)$id;
1206
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1207
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1208
-        if ($cursor != null) $parameters['cursor'] = (int)$cursor;
1368
+        if ($id != null) {
1369
+        	$parameters['id'] = (string)$id;
1370
+        }
1371
+        if ($userId != null) {
1372
+        	$parameters['user_id'] = (string)$userId;
1373
+        }
1374
+        if ($screenName != null) {
1375
+        	$parameters['screen_name'] = (string)$screenName;
1376
+        }
1377
+        if ($cursor != null) {
1378
+        	$parameters['cursor'] = (int)$cursor;
1379
+        }
1209 1380
 
1210 1381
         // make the call
1211 1382
         return (array)$this->doCall('statuses/followers.json', $parameters);
@@ -1235,7 +1406,9 @@  discard block
 block discarded – undo
1235 1406
     {
1236 1407
         // build parameters
1237 1408
         $parameters = array();
1238
-        if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1409
+        if ($exclude != null) {
1410
+        	$parameters['exclude'] = (string)$exclude;
1411
+        }
1239 1412
 
1240 1413
         // make the call
1241 1414
         return (array)$this->doCall('trends/current.json', $parameters);
@@ -1252,8 +1425,12 @@  discard block
 block discarded – undo
1252 1425
     {
1253 1426
         // build parameters
1254 1427
         $parameters = array();
1255
-        if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1256
-        if ($date != null) $parameters['date'] = (string)$date;
1428
+        if ($exclude != null) {
1429
+        	$parameters['exclude'] = (string)$exclude;
1430
+        }
1431
+        if ($date != null) {
1432
+        	$parameters['date'] = (string)$date;
1433
+        }
1257 1434
 
1258 1435
         // make the call
1259 1436
         return (array)$this->doCall('trends/daily.json', $parameters);
@@ -1270,8 +1447,12 @@  discard block
 block discarded – undo
1270 1447
     {
1271 1448
         // build parameters
1272 1449
         $parameters = array();
1273
-        if ($exclude != null) $parameters['exclude'] = (string)$exclude;
1274
-        if ($date != null) $parameters['date'] = (string)$date;
1450
+        if ($exclude != null) {
1451
+        	$parameters['exclude'] = (string)$exclude;
1452
+        }
1453
+        if ($date != null) {
1454
+        	$parameters['date'] = (string)$date;
1455
+        }
1275 1456
 
1276 1457
         // make the call
1277 1458
         return (array)$this->doCall('trends/weekly.json', $parameters);
@@ -1298,12 +1479,18 @@  discard block
 block discarded – undo
1298 1479
         $allowedModes = array('public', 'private');
1299 1480
 
1300 1481
         // validate
1301
-        if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.');
1482
+        if ($mode != null && !in_array($mode, $allowedModes)) {
1483
+        	throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.');
1484
+        }
1302 1485
 
1303 1486
         // build parameters
1304 1487
         $parameters['name'] = (string)$name;
1305
-        if ($mode != null) $parameters['mode'] = (string)$mode;
1306
-        if ($description != null) $parameters['description'] = (string)$description;
1488
+        if ($mode != null) {
1489
+        	$parameters['mode'] = (string)$mode;
1490
+        }
1491
+        if ($description != null) {
1492
+        	$parameters['description'] = (string)$description;
1493
+        }
1307 1494
 
1308 1495
         // make the call
1309 1496
         return (array)$this->doCall((string)$user . '/lists.json', $parameters, true, 'POST');
@@ -1319,7 +1506,9 @@  discard block
 block discarded – undo
1319 1506
     public function userLists($user, $cursor = null)
1320 1507
     {
1321 1508
         $parameters = null;
1322
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1509
+        if ($cursor != null) {
1510
+        	$parameters['cursor'] = (string)$cursor;
1511
+        }
1323 1512
 
1324 1513
         // make the call
1325 1514
         return (array)$this->doCall((string)$user . '/lists.json', $parameters, true);
@@ -1359,12 +1548,20 @@  discard block
 block discarded – undo
1359 1548
         $allowedModes = array('public', 'private');
1360 1549
 
1361 1550
         // validate
1362
-        if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.');
1551
+        if ($mode != null && !in_array($mode, $allowedModes)) {
1552
+        	throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.');
1553
+        }
1363 1554
 
1364 1555
         // build parameters
1365
-        if ($name != null) $parameters['name'] = (string)$name;
1366
-        if ($mode != null) $parameters['mode'] = (string)$mode;
1367
-        if ($description != null) $parameters['description'] = (string)$description;
1556
+        if ($name != null) {
1557
+        	$parameters['name'] = (string)$name;
1558
+        }
1559
+        if ($mode != null) {
1560
+        	$parameters['mode'] = (string)$mode;
1561
+        }
1562
+        if ($description != null) {
1563
+        	$parameters['description'] = (string)$description;
1564
+        }
1368 1565
 
1369 1566
         // make the call
1370 1567
         return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '.json', $parameters, true, 'POST');
@@ -1390,14 +1587,24 @@  discard block
 block discarded – undo
1390 1587
     public function userListsIdStatuses($user, $id, $sinceId = null, $maxId = null, $count = null, $page = null)
1391 1588
     {
1392 1589
         // validate
1393
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1590
+        if ($count != null && $count > 200) {
1591
+        	throw new TwitterException('Count may not be greater than 200.');
1592
+        }
1394 1593
 
1395 1594
         // build parameters
1396 1595
         $parameters = array();
1397
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1398
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1399
-        if ($count != null) $parameters['per_page'] = (int)$count;
1400
-        if ($page != null) $parameters['page'] = (int)$page;
1596
+        if ($sinceId != null) {
1597
+        	$parameters['since_id'] = (string)$sinceId;
1598
+        }
1599
+        if ($maxId != null) {
1600
+        	$parameters['max_id'] = (string)$maxId;
1601
+        }
1602
+        if ($count != null) {
1603
+        	$parameters['per_page'] = (int)$count;
1604
+        }
1605
+        if ($page != null) {
1606
+        	$parameters['page'] = (int)$page;
1607
+        }
1401 1608
 
1402 1609
         // make the call
1403 1610
         return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '/statuses.json', $parameters);
@@ -1413,7 +1620,9 @@  discard block
 block discarded – undo
1413 1620
     public function userListsMemberships($user, $cursor = null)
1414 1621
     {
1415 1622
         $parameters = null;
1416
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1623
+        if ($cursor != null) {
1624
+        	$parameters['cursor'] = (string)$cursor;
1625
+        }
1417 1626
 
1418 1627
         // make the call
1419 1628
         return (array)$this->doCall((string)$user . '/lists/memberships.json', $parameters, true);
@@ -1429,7 +1638,9 @@  discard block
 block discarded – undo
1429 1638
     public function userListsSubscriptions($user, $cursor = null)
1430 1639
     {
1431 1640
         $parameters = null;
1432
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1641
+        if ($cursor != null) {
1642
+        	$parameters['cursor'] = (string)$cursor;
1643
+        }
1433 1644
 
1434 1645
         // make the call
1435 1646
         return (array)$this->doCall((string)$user . '/lists/subscriptions.json', $parameters, true);
@@ -1448,7 +1659,9 @@  discard block
 block discarded – undo
1448 1659
     public function userListMembers($user, $id, $cursor = null)
1449 1660
     {
1450 1661
         $parameters = null;
1451
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1662
+        if ($cursor != null) {
1663
+        	$parameters['cursor'] = (string)$cursor;
1664
+        }
1452 1665
 
1453 1666
         // make the call
1454 1667
         return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true);
@@ -1508,7 +1721,9 @@  discard block
 block discarded – undo
1508 1721
         catch (TwitterException $e) {
1509 1722
             if ($e->getMessage() === 'The specified user is not a member of this list') {
1510 1723
                 return false;
1511
-            } else throw $e;
1724
+            } else {
1725
+            	throw $e;
1726
+            }
1512 1727
         }
1513 1728
     }
1514 1729
 
@@ -1525,7 +1740,9 @@  discard block
 block discarded – undo
1525 1740
     public function userListSubscribers($user, $id, $cursor = null)
1526 1741
     {
1527 1742
         $parameters = null;
1528
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
1743
+        if ($cursor != null) {
1744
+        	$parameters['cursor'] = (string)$cursor;
1745
+        }
1529 1746
 
1530 1747
         // make the call
1531 1748
         return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', $parameters, true);
@@ -1579,7 +1796,9 @@  discard block
 block discarded – undo
1579 1796
         catch (TwitterException $e) {
1580 1797
             if ($e->getMessage() === 'The specified user is not a subscriber of this list') {
1581 1798
                 return false;
1582
-            } else throw $e;
1799
+            } else {
1800
+            	throw $e;
1801
+            }
1583 1802
         }
1584 1803
 
1585 1804
     }
@@ -1604,14 +1823,24 @@  discard block
 block discarded – undo
1604 1823
     public function directMessages($sinceId = null, $maxId = null, $count = null, $page = null)
1605 1824
     {
1606 1825
         // validate
1607
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1826
+        if ($count != null && $count > 200) {
1827
+        	throw new TwitterException('Count may not be greater than 200.');
1828
+        }
1608 1829
 
1609 1830
         // build parameters
1610 1831
         $parameters = array();
1611
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1612
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1613
-        if ($count != null) $parameters['count'] = (int)$count;
1614
-        if ($page != null) $parameters['page'] = (int)$page;
1832
+        if ($sinceId != null) {
1833
+        	$parameters['since_id'] = (string)$sinceId;
1834
+        }
1835
+        if ($maxId != null) {
1836
+        	$parameters['max_id'] = (string)$maxId;
1837
+        }
1838
+        if ($count != null) {
1839
+        	$parameters['count'] = (int)$count;
1840
+        }
1841
+        if ($page != null) {
1842
+        	$parameters['page'] = (int)$page;
1843
+        }
1615 1844
 
1616 1845
         // make the call
1617 1846
         return (array)$this->doCall('direct_messages.json', $parameters, true);
@@ -1635,14 +1864,24 @@  discard block
 block discarded – undo
1635 1864
     public function directMessagesSent($sinceId = null, $maxId = null, $count = null, $page = null)
1636 1865
     {
1637 1866
         // validate
1638
-        if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.');
1867
+        if ($count != null && $count > 200) {
1868
+        	throw new TwitterException('Count may not be greater than 200.');
1869
+        }
1639 1870
 
1640 1871
         // build parameters
1641 1872
         $parameters = array();
1642
-        if ($sinceId != null) $parameters['since_id'] = (string)$sinceId;
1643
-        if ($maxId != null) $parameters['max_id'] = (string)$maxId;
1644
-        if ($count != null) $parameters['count'] = (int)$count;
1645
-        if ($page != null) $parameters['page'] = (int)$page;
1873
+        if ($sinceId != null) {
1874
+        	$parameters['since_id'] = (string)$sinceId;
1875
+        }
1876
+        if ($maxId != null) {
1877
+        	$parameters['max_id'] = (string)$maxId;
1878
+        }
1879
+        if ($count != null) {
1880
+        	$parameters['count'] = (int)$count;
1881
+        }
1882
+        if ($page != null) {
1883
+        	$parameters['page'] = (int)$page;
1884
+        }
1646 1885
 
1647 1886
         // make the call
1648 1887
         return (array)$this->doCall('direct_messages/sent.json', $parameters, true);
@@ -1666,13 +1905,21 @@  discard block
 block discarded – undo
1666 1905
     public function directMessagesNew($text, $id = null, $userId = null, $screenName = null)
1667 1906
     {
1668 1907
         // validate
1669
-        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
+        }
1670 1911
 
1671 1912
         // build parameters
1672 1913
         $parameters['text'] = (string)$text;
1673
-        if ($id != null) $parameters['user'] = (string)$id;
1674
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1675
-        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
+        }
1676 1923
 
1677 1924
         // make the call
1678 1925
         return (array)$this->doCall('direct_messages/new.json', $parameters, true, 'POST');
@@ -1715,12 +1962,20 @@  discard block
 block discarded – undo
1715 1962
     public function friendshipsCreate($id = null, $userId = null, $screenName = null, $follow = false)
1716 1963
     {
1717 1964
         // validate
1718
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
1965
+        if ($id == '' && $userId == '' && $screenName == '') {
1966
+        	throw new TwitterException('Specify an id or an userId or a screenName.');
1967
+        }
1719 1968
 
1720 1969
         // build parameters
1721
-        if ($id != null) $parameters['id'] = (string)$id;
1722
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1723
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1970
+        if ($id != null) {
1971
+        	$parameters['id'] = (string)$id;
1972
+        }
1973
+        if ($userId != null) {
1974
+        	$parameters['user_id'] = (string)$userId;
1975
+        }
1976
+        if ($screenName != null) {
1977
+        	$parameters['screen_name'] = (string)$screenName;
1978
+        }
1724 1979
         $parameters['follow'] = $follow ? 'true' : 'false';
1725 1980
 
1726 1981
         // make the call
@@ -1744,12 +1999,20 @@  discard block
 block discarded – undo
1744 1999
     public function friendshipsDestroy($id = null, $userId = null, $screenName = null)
1745 2000
     {
1746 2001
         // validate
1747
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2002
+        if ($id == '' && $userId == '' && $screenName == '') {
2003
+        	throw new TwitterException('Specify an id or an userId or a screenName.');
2004
+        }
1748 2005
 
1749 2006
         // build parameters
1750
-        if ($id != null) $parameters['id'] = (string)$id;
1751
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1752
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2007
+        if ($id != null) {
2008
+        	$parameters['id'] = (string)$id;
2009
+        }
2010
+        if ($userId != null) {
2011
+        	$parameters['user_id'] = (string)$userId;
2012
+        }
2013
+        if ($screenName != null) {
2014
+        	$parameters['screen_name'] = (string)$screenName;
2015
+        }
1753 2016
 
1754 2017
         // make the call
1755 2018
         return (array)$this->doCall('friendships/destroy.json', $parameters, true, 'POST');
@@ -1790,14 +2053,26 @@  discard block
 block discarded – undo
1790 2053
     public function friendshipsShow($sourceId = null, $sourceScreenName = null, $targetId = null, $targetScreenName = null)
1791 2054
     {
1792 2055
         // validate
1793
-        if ($sourceId == '' && $sourceScreenName == '') throw new TwitterException('Specify an sourceId or a sourceScreenName.');
1794
-        if ($targetId == '' && $targetScreenName == '') throw new TwitterException('Specify an targetId or a targetScreenName.');
2056
+        if ($sourceId == '' && $sourceScreenName == '') {
2057
+        	throw new TwitterException('Specify an sourceId or a sourceScreenName.');
2058
+        }
2059
+        if ($targetId == '' && $targetScreenName == '') {
2060
+        	throw new TwitterException('Specify an targetId or a targetScreenName.');
2061
+        }
1795 2062
 
1796 2063
         // build parameters
1797
-        if ($sourceId != null) $parameters['source_id'] = (string)$sourceId;
1798
-        if ($sourceScreenName != null) $parameters['source_screen_name'] = (string)$sourceScreenName;
1799
-        if ($targetId != null) $parameters['target_id'] = (string)$targetId;
1800
-        if ($targetScreenName != null) $parameters['target_screen_name'] = (string)$targetScreenName;
2064
+        if ($sourceId != null) {
2065
+        	$parameters['source_id'] = (string)$sourceId;
2066
+        }
2067
+        if ($sourceScreenName != null) {
2068
+        	$parameters['source_screen_name'] = (string)$sourceScreenName;
2069
+        }
2070
+        if ($targetId != null) {
2071
+        	$parameters['target_id'] = (string)$targetId;
2072
+        }
2073
+        if ($targetScreenName != null) {
2074
+        	$parameters['target_screen_name'] = (string)$targetScreenName;
2075
+        }
1801 2076
 
1802 2077
         // make the call
1803 2078
         return (array)$this->doCall('friendships/show.json', $parameters);
@@ -1812,7 +2087,9 @@  discard block
 block discarded – undo
1812 2087
     public function friendshipsIncoming($cursor = null)
1813 2088
     {
1814 2089
         $parameters = null;
1815
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
2090
+        if ($cursor != null) {
2091
+        	$parameters['cursor'] = (string)$cursor;
2092
+        }
1816 2093
 
1817 2094
         // make the call
1818 2095
         return (array)$this->doCall('friendships/incoming.json', $parameters, true);
@@ -1827,7 +2104,9 @@  discard block
 block discarded – undo
1827 2104
     public function friendshipsOutgoing($cursor = null)
1828 2105
     {
1829 2106
         $parameters = null;
1830
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
2107
+        if ($cursor != null) {
2108
+        	$parameters['cursor'] = (string)$cursor;
2109
+        }
1831 2110
 
1832 2111
         // make the call
1833 2112
         return (array)$this->doCall('friendships/outgoing.json', $parameters, true);
@@ -1853,13 +2132,23 @@  discard block
 block discarded – undo
1853 2132
     public function friendsIds($id = null, $userId = null, $screenName = null, $cursor = null)
1854 2133
     {
1855 2134
         // validate
1856
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2135
+        if ($id == '' && $userId == '' && $screenName == '') {
2136
+        	throw new TwitterException('Specify an id or an userId or a screenName.');
2137
+        }
1857 2138
 
1858 2139
         // build parameters
1859
-        if ($id != null) $parameters['id'] = (string)$id;
1860
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1861
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1862
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
2140
+        if ($id != null) {
2141
+        	$parameters['id'] = (string)$id;
2142
+        }
2143
+        if ($userId != null) {
2144
+        	$parameters['user_id'] = (string)$userId;
2145
+        }
2146
+        if ($screenName != null) {
2147
+        	$parameters['screen_name'] = (string)$screenName;
2148
+        }
2149
+        if ($cursor != null) {
2150
+        	$parameters['cursor'] = (string)$cursor;
2151
+        }
1863 2152
 
1864 2153
         // make the call
1865 2154
         return (array)$this->doCall('friends/ids.json', $parameters);
@@ -1883,13 +2172,23 @@  discard block
 block discarded – undo
1883 2172
     public function followersIds($id = null, $userId = null, $screenName = null, $cursor = null)
1884 2173
     {
1885 2174
         // validate
1886
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2175
+        if ($id == '' && $userId == '' && $screenName == '') {
2176
+        	throw new TwitterException('Specify an id or an userId or a screenName.');
2177
+        }
1887 2178
 
1888 2179
         // build parameters
1889
-        if ($id != null) $parameters['id'] = (string)$id;
1890
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
1891
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
1892
-        if ($cursor != null) $parameters['cursor'] = (string)$cursor;
2180
+        if ($id != null) {
2181
+        	$parameters['id'] = (string)$id;
2182
+        }
2183
+        if ($userId != null) {
2184
+        	$parameters['user_id'] = (string)$userId;
2185
+        }
2186
+        if ($screenName != null) {
2187
+        	$parameters['screen_name'] = (string)$screenName;
2188
+        }
2189
+        if ($cursor != null) {
2190
+        	$parameters['cursor'] = (string)$cursor;
2191
+        }
1893 2192
 
1894 2193
         // make the call
1895 2194
         return (array)$this->doCall('followers/ids.json', $parameters);
@@ -1932,7 +2231,9 @@  discard block
 block discarded – undo
1932 2231
         catch (TwitterException $e) {
1933 2232
             if ($e->getMessage() === 'Logged out.') {
1934 2233
                 return true;
1935
-            } else throw $e;
2234
+            } else {
2235
+            	throw $e;
2236
+            }
1936 2237
         }
1937 2238
     }
1938 2239
 
@@ -1974,14 +2275,26 @@  discard block
 block discarded – undo
1974 2275
         // validate
1975 2276
         if ($profileBackgroundColor == '' && $profileTextColor == '' && $profileLinkColor == '' && $profileSidebarFillColor == ''
1976 2277
             && $profileSidebarBorderColor == ''
1977
-        ) throw new TwitterException('Specify a profileBackgroundColor, profileTextColor, profileLinkColor, profileSidebarFillColor or a profileSidebarBorderColor.');
2278
+        ) {
2279
+        	throw new TwitterException('Specify a profileBackgroundColor, profileTextColor, profileLinkColor, profileSidebarFillColor or a profileSidebarBorderColor.');
2280
+        }
1978 2281
 
1979 2282
         // build parameters
1980
-        if ($profileBackgroundColor != null) $parameters['profile_background_color'] = (string)$profileBackgroundColor;
1981
-        if ($profileTextColor != null) $parameters['profile_text_color'] = (string)$profileTextColor;
1982
-        if ($profileLinkColor != null) $parameters['profile_link_color'] = (string)$profileLinkColor;
1983
-        if ($profileSidebarFillColor != null) $parameters['profile_sidebar_fill_color'] = (string)$profileSidebarFillColor;
1984
-        if ($profileSidebarBorderColor != null) $parameters['profile_sidebar_border_color'] = (string)$profileSidebarBorderColor;
2283
+        if ($profileBackgroundColor != null) {
2284
+        	$parameters['profile_background_color'] = (string)$profileBackgroundColor;
2285
+        }
2286
+        if ($profileTextColor != null) {
2287
+        	$parameters['profile_text_color'] = (string)$profileTextColor;
2288
+        }
2289
+        if ($profileLinkColor != null) {
2290
+        	$parameters['profile_link_color'] = (string)$profileLinkColor;
2291
+        }
2292
+        if ($profileSidebarFillColor != null) {
2293
+        	$parameters['profile_sidebar_fill_color'] = (string)$profileSidebarFillColor;
2294
+        }
2295
+        if ($profileSidebarBorderColor != null) {
2296
+        	$parameters['profile_sidebar_border_color'] = (string)$profileSidebarBorderColor;
2297
+        }
1985 2298
 
1986 2299
         // make the call
1987 2300
         return (array)$this->doCall('account/update_profile_colors.json', $parameters, true, 'POST');
@@ -2000,7 +2313,9 @@  discard block
 block discarded – undo
2000 2313
         throw new TwitterException('Not implemented');
2001 2314
 
2002 2315
         // validate
2003
-        if (!file_exists($image)) throw new TwitterException('Image (' . $image . ') doesn\'t exists.');
2316
+        if (!file_exists($image)) {
2317
+        	throw new TwitterException('Image (' . $image . ') doesn\'t exists.');
2318
+        }
2004 2319
 
2005 2320
         // make the call
2006 2321
         return (array)$this->doCall('account/update_profile_image.json', null, true, 'POST', $image);
@@ -2020,10 +2335,14 @@  discard block
 block discarded – undo
2020 2335
         throw new TwitterException('Not implemented');
2021 2336
 
2022 2337
         // validate
2023
-        if (!file_exists($image)) throw new TwitterException('Image (' . $image . ') doesn\'t exists.');
2338
+        if (!file_exists($image)) {
2339
+        	throw new TwitterException('Image (' . $image . ') doesn\'t exists.');
2340
+        }
2024 2341
 
2025 2342
         // build parameters
2026
-        if ($tile) $parameters['tile'] = 'true';
2343
+        if ($tile) {
2344
+        	$parameters['tile'] = 'true';
2345
+        }
2027 2346
 
2028 2347
         // make the call
2029 2348
         return (array)$this->doCall('account/update_profile_background_image.json', $parameters, true, 'POST', $image);
@@ -2042,10 +2361,18 @@  discard block
 block discarded – undo
2042 2361
     {
2043 2362
         // build parameters
2044 2363
         $parameters = null;
2045
-        if ($name != null) $parameters['name'] = (string)$name;
2046
-        if ($url != null) $parameters['url'] = (string)$url;
2047
-        if ($location != null) $parameters['location'] = (string)$location;
2048
-        if ($description != null) $parameters['description'] = (string)$description;
2364
+        if ($name != null) {
2365
+        	$parameters['name'] = (string)$name;
2366
+        }
2367
+        if ($url != null) {
2368
+        	$parameters['url'] = (string)$url;
2369
+        }
2370
+        if ($location != null) {
2371
+        	$parameters['location'] = (string)$location;
2372
+        }
2373
+        if ($description != null) {
2374
+        	$parameters['description'] = (string)$description;
2375
+        }
2049 2376
 
2050 2377
         // make the call
2051 2378
         return (array)$this->doCall('account/update_profile.json', $parameters, true, 'POST');
@@ -2064,8 +2391,12 @@  discard block
 block discarded – undo
2064 2391
     {
2065 2392
         // build parameters
2066 2393
         $parameters = null;
2067
-        if ($id != null) $parameters['id'] = (string)$id;
2068
-        if ($page != null) $parameters['page'] = (int)$page;
2394
+        if ($id != null) {
2395
+        	$parameters['id'] = (string)$id;
2396
+        }
2397
+        if ($page != null) {
2398
+        	$parameters['page'] = (int)$page;
2399
+        }
2069 2400
 
2070 2401
         // make the call
2071 2402
         return (array)$this->doCall('favorites.json', $parameters, true);
@@ -2113,12 +2444,20 @@  discard block
 block discarded – undo
2113 2444
     public function notificationsFollow($id = null, $userId = null, $screenName = null)
2114 2445
     {
2115 2446
         // validate
2116
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2447
+        if ($id == '' && $userId == '' && $screenName == '') {
2448
+        	throw new TwitterException('Specify an id or an userId or a screenName.');
2449
+        }
2117 2450
 
2118 2451
         // build parameters
2119
-        if ($id != null) $parameters['id'] = (string)$id;
2120
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2121
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2452
+        if ($id != null) {
2453
+        	$parameters['id'] = (string)$id;
2454
+        }
2455
+        if ($userId != null) {
2456
+        	$parameters['user_id'] = (string)$userId;
2457
+        }
2458
+        if ($screenName != null) {
2459
+        	$parameters['screen_name'] = (string)$screenName;
2460
+        }
2122 2461
 
2123 2462
         // make the call
2124 2463
         return (array)$this->doCall('notifications/follow.json', $parameters, true, 'POST');
@@ -2140,12 +2479,20 @@  discard block
 block discarded – undo
2140 2479
     public function notificationsLeave($id = null, $userId = null, $screenName = null)
2141 2480
     {
2142 2481
         // validate
2143
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2482
+        if ($id == '' && $userId == '' && $screenName == '') {
2483
+        	throw new TwitterException('Specify an id or an userId or a screenName.');
2484
+        }
2144 2485
 
2145 2486
         // build parameters
2146
-        if ($id != null) $parameters['id'] = (string)$id;
2147
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2148
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2487
+        if ($id != null) {
2488
+        	$parameters['id'] = (string)$id;
2489
+        }
2490
+        if ($userId != null) {
2491
+        	$parameters['user_id'] = (string)$userId;
2492
+        }
2493
+        if ($screenName != null) {
2494
+        	$parameters['screen_name'] = (string)$screenName;
2495
+        }
2149 2496
 
2150 2497
         // make the call
2151 2498
         return (array)$this->doCall('notifications/leave.json', $parameters, true, 'POST');
@@ -2169,12 +2516,20 @@  discard block
 block discarded – undo
2169 2516
     public function blocksCreate($id = null, $userId = null, $screenName = null)
2170 2517
     {
2171 2518
         // validate
2172
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2519
+        if ($id == '' && $userId == '' && $screenName == '') {
2520
+        	throw new TwitterException('Specify an id or an userId or a screenName.');
2521
+        }
2173 2522
 
2174 2523
         // build parameters
2175
-        if ($id != null) $parameters['id'] = (string)$id;
2176
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2177
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2524
+        if ($id != null) {
2525
+        	$parameters['id'] = (string)$id;
2526
+        }
2527
+        if ($userId != null) {
2528
+        	$parameters['user_id'] = (string)$userId;
2529
+        }
2530
+        if ($screenName != null) {
2531
+        	$parameters['screen_name'] = (string)$screenName;
2532
+        }
2178 2533
 
2179 2534
         // make the call
2180 2535
         return (array)$this->doCall('blocks/create.json', $parameters, true, 'POST');
@@ -2196,12 +2551,20 @@  discard block
 block discarded – undo
2196 2551
     public function blocksDestroy($id = null, $userId = null, $screenName = null)
2197 2552
     {
2198 2553
         // validate
2199
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2554
+        if ($id == '' && $userId == '' && $screenName == '') {
2555
+        	throw new TwitterException('Specify an id or an userId or a screenName.');
2556
+        }
2200 2557
 
2201 2558
         // build parameters
2202
-        if ($id != null) $parameters['id'] = (string)$id;
2203
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2204
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2559
+        if ($id != null) {
2560
+        	$parameters['id'] = (string)$id;
2561
+        }
2562
+        if ($userId != null) {
2563
+        	$parameters['user_id'] = (string)$userId;
2564
+        }
2565
+        if ($screenName != null) {
2566
+        	$parameters['screen_name'] = (string)$screenName;
2567
+        }
2205 2568
 
2206 2569
         // make the call
2207 2570
         return (array)$this->doCall('blocks/destroy.json', $parameters, true, 'POST');
@@ -2223,12 +2586,20 @@  discard block
 block discarded – undo
2223 2586
     public function blocksExists($id = null, $userId = null, $screenName = null)
2224 2587
     {
2225 2588
         // validate
2226
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2589
+        if ($id == '' && $userId == '' && $screenName == '') {
2590
+        	throw new TwitterException('Specify an id or an userId or a screenName.');
2591
+        }
2227 2592
 
2228 2593
         // build parameters
2229
-        if ($id != null) $parameters['id'] = (string)$id;
2230
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2231
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2594
+        if ($id != null) {
2595
+        	$parameters['id'] = (string)$id;
2596
+        }
2597
+        if ($userId != null) {
2598
+        	$parameters['user_id'] = (string)$userId;
2599
+        }
2600
+        if ($screenName != null) {
2601
+        	$parameters['screen_name'] = (string)$screenName;
2602
+        }
2232 2603
 
2233 2604
         try {
2234 2605
             // make the call
@@ -2237,7 +2608,9 @@  discard block
 block discarded – undo
2237 2608
         catch (TwitterException $e) {
2238 2609
             if ($e->getMessage() === 'You are not blocking this user.') {
2239 2610
                 return false;
2240
-            } else throw $e;
2611
+            } else {
2612
+            	throw $e;
2613
+            }
2241 2614
         }
2242 2615
     }
2243 2616
 
@@ -2251,7 +2624,9 @@  discard block
 block discarded – undo
2251 2624
     {
2252 2625
         // build parameters
2253 2626
         $parameters = null;
2254
-        if ($page != null) $parameters['page'] = (int)$page;
2627
+        if ($page != null) {
2628
+        	$parameters['page'] = (int)$page;
2629
+        }
2255 2630
 
2256 2631
         // make the call
2257 2632
         return (array)$this->doCall('blocks/blocking.json', $parameters, true);
@@ -2286,12 +2661,20 @@  discard block
 block discarded – undo
2286 2661
     public function reportSpam($id = null, $userId = null, $screenName = null)
2287 2662
     {
2288 2663
         // validate
2289
-        if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.');
2664
+        if ($id == '' && $userId == '' && $screenName == '') {
2665
+        	throw new TwitterException('Specify an id or an userId or a screenName.');
2666
+        }
2290 2667
 
2291 2668
         // build parameters
2292
-        if ($id != null) $parameters['id'] = (string)$id;
2293
-        if ($userId != null) $parameters['user_id'] = (string)$userId;
2294
-        if ($screenName != null) $parameters['screen_name'] = (string)$screenName;
2669
+        if ($id != null) {
2670
+        	$parameters['id'] = (string)$id;
2671
+        }
2672
+        if ($userId != null) {
2673
+        	$parameters['user_id'] = (string)$userId;
2674
+        }
2675
+        if ($screenName != null) {
2676
+        	$parameters['screen_name'] = (string)$screenName;
2677
+        }
2295 2678
 
2296 2679
         // make the call
2297 2680
         return (array)$this->doCall('report_spam.json', $parameters, true, 'POST');
@@ -2369,17 +2752,25 @@  discard block
 block discarded – undo
2369 2752
         $parameters = array();
2370 2753
 
2371 2754
         // set callback
2372
-        if ($callbackURL != null) $parameters['oauth_callback'] = (string)$callbackURL;
2755
+        if ($callbackURL != null) {
2756
+        	$parameters['oauth_callback'] = (string)$callbackURL;
2757
+        }
2373 2758
 
2374 2759
         // make the call
2375 2760
         $response = $this->doOAuthCall('request_token', $parameters);
2376 2761
 
2377 2762
         // validate
2378
-        if (!isset($response['oauth_token'], $response['oauth_token_secret'])) throw new TwitterException(implode(', ', array_keys($response)));
2763
+        if (!isset($response['oauth_token'], $response['oauth_token_secret'])) {
2764
+        	throw new TwitterException(implode(', ', array_keys($response)));
2765
+        }
2379 2766
 
2380 2767
         // set some properties
2381
-        if (isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']);
2382
-        if (isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']);
2768
+        if (isset($response['oauth_token'])) {
2769
+        	$this->setOAuthToken($response['oauth_token']);
2770
+        }
2771
+        if (isset($response['oauth_token_secret'])) {
2772
+        	$this->setOAuthTokenSecret($response['oauth_token_secret']);
2773
+        }
2383 2774
 
2384 2775
         // return
2385 2776
         return $response;
@@ -2404,8 +2795,12 @@  discard block
 block discarded – undo
2404 2795
         $response = $this->doOAuthCall('access_token', $parameters);
2405 2796
 
2406 2797
         // set some properties
2407
-        if (isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']);
2408
-        if (isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']);
2798
+        if (isset($response['oauth_token'])) {
2799
+        	$this->setOAuthToken($response['oauth_token']);
2800
+        }
2801
+        if (isset($response['oauth_token_secret'])) {
2802
+        	$this->setOAuthTokenSecret($response['oauth_token_secret']);
2803
+        }
2409 2804
 
2410 2805
         // return
2411 2806
         return $response;
@@ -2448,8 +2843,12 @@  discard block
 block discarded – undo
2448 2843
     {
2449 2844
         // build parameters
2450 2845
         $parameters = null;
2451
-        if ($lat != null) $parameters['lat_for_trends'] = (float)$lat;
2452
-        if ($long != null) $parameters['long_for_trends'] = (float)$long;
2846
+        if ($lat != null) {
2847
+        	$parameters['lat_for_trends'] = (float)$lat;
2848
+        }
2849
+        if ($long != null) {
2850
+        	$parameters['long_for_trends'] = (float)$long;
2851
+        }
2453 2852
 
2454 2853
         // make the call
2455 2854
         return (array)$this->doCall('trends/available.json', $parameters);
@@ -2490,9 +2889,15 @@  discard block
 block discarded – undo
2490 2889
         // build parameters
2491 2890
         $parameters['lat']  = (float)$lat;
2492 2891
         $parameters['long'] = (float)$long;
2493
-        if ($accuracy != null) $parameters['accuracy'] = (string)$accuracy;
2494
-        if ($granularity != null) $parameters['granularity'] = (string)$granularity;
2495
-        if ($maxResults != null) $parameters['max_results'] = (int)$maxResults;
2892
+        if ($accuracy != null) {
2893
+        	$parameters['accuracy'] = (string)$accuracy;
2894
+        }
2895
+        if ($granularity != null) {
2896
+        	$parameters['granularity'] = (string)$granularity;
2897
+        }
2898
+        if ($maxResults != null) {
2899
+        	$parameters['max_results'] = (int)$maxResults;
2900
+        }
2496 2901
 
2497 2902
         // make the call
2498 2903
         return (array)$this->doCall('geo/reverse_geocode.json', $parameters);
@@ -2509,7 +2914,9 @@  discard block
 block discarded – undo
2509 2914
     {
2510 2915
         // build parameters
2511 2916
         $parameters = null;
2512
-        if ($placeId != null) $parameters['place_id'] = (string)$placeId;
2917
+        if ($placeId != null) {
2918
+        	$parameters['place_id'] = (string)$placeId;
2919
+        }
2513 2920
 
2514 2921
         // make the call
2515 2922
         return (array)$this->doCall('geo/id/' . (string)$id . '.json', $parameters);
Please login to merge, or discard this patch.