0
|
1 <?php
|
|
2
|
|
3 namespace Abraham\TwitterOAuth;
|
|
4
|
|
5 /**
|
|
6 * Handle setting and storing config for TwitterOAuth.
|
|
7 *
|
|
8 * @author Abraham Williams <[email protected]>
|
|
9 */
|
|
10 class Config
|
|
11 {
|
|
12 /** @var int How long to wait for a response from the API */
|
|
13 protected $timeout = 5;
|
|
14 /** @var int how long to wait while connecting to the API */
|
|
15 protected $connectionTimeout = 5;
|
|
16 /**
|
|
17 * Decode JSON Response as associative Array
|
|
18 *
|
|
19 * @see http://php.net/manual/en/function.json-decode.php
|
|
20 *
|
|
21 * @var bool
|
|
22 */
|
|
23 protected $decodeJsonAsArray = false;
|
|
24 /** @var string User-Agent header */
|
|
25 protected $userAgent = 'TwitterOAuth (+https://twitteroauth.com)';
|
|
26 /** @var array Store proxy connection details */
|
|
27 protected $proxy = [];
|
|
28
|
|
29 /** @var bool Whether to encode the curl requests with gzip or not */
|
|
30 protected $gzipEncoding = true;
|
|
31
|
|
32 /**
|
|
33 * Set the connection and response timeouts.
|
|
34 *
|
|
35 * @param int $connectionTimeout
|
|
36 * @param int $timeout
|
|
37 */
|
|
38 public function setTimeouts($connectionTimeout, $timeout)
|
|
39 {
|
|
40 $this->connectionTimeout = (int)$connectionTimeout;
|
|
41 $this->timeout = (int)$timeout;
|
|
42 }
|
|
43
|
|
44 /**
|
|
45 * @param bool $value
|
|
46 */
|
|
47 public function setDecodeJsonAsArray($value)
|
|
48 {
|
|
49 $this->decodeJsonAsArray = (bool)$value;
|
|
50 }
|
|
51
|
|
52 /**
|
|
53 * @param string $userAgent
|
|
54 */
|
|
55 public function setUserAgent($userAgent)
|
|
56 {
|
|
57 $this->userAgent = (string)$userAgent;
|
|
58 }
|
|
59
|
|
60 /**
|
|
61 * @param array $proxy
|
|
62 */
|
|
63 public function setProxy(array $proxy)
|
|
64 {
|
|
65 $this->proxy = $proxy;
|
|
66 }
|
|
67
|
|
68 /**
|
|
69 * Whether to encode the curl requests with gzip or not.
|
|
70 *
|
|
71 * @param boolean $gzipEncoding
|
|
72 */
|
|
73 public function setGzipEncoding($gzipEncoding)
|
|
74 {
|
|
75 $this->gzipEncoding = (bool)$gzipEncoding;
|
|
76 }
|
|
77 }
|