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
|
|
|
/** @var integer Size for Chunked Uploads */ |
33
|
|
|
protected $chunkSize = 250000; // 0.25 MegaByte |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Set the connection and response timeouts. |
37
|
|
|
* |
38
|
|
|
* @param int $connectionTimeout |
39
|
|
|
* @param int $timeout |
40
|
|
|
*/ |
41
|
|
|
public function setTimeouts($connectionTimeout, $timeout) |
42
|
|
|
{ |
43
|
|
|
$this->connectionTimeout = (int)$connectionTimeout; |
44
|
|
|
$this->timeout = (int)$timeout; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param bool $value |
49
|
|
|
*/ |
50
|
|
|
public function setDecodeJsonAsArray($value) |
51
|
|
|
{ |
52
|
|
|
$this->decodeJsonAsArray = (bool)$value; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param string $userAgent |
57
|
|
|
*/ |
58
|
|
|
public function setUserAgent($userAgent) |
59
|
|
|
{ |
60
|
|
|
$this->userAgent = (string)$userAgent; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param array $proxy |
65
|
|
|
*/ |
66
|
|
|
public function setProxy(array $proxy) |
67
|
|
|
{ |
68
|
|
|
$this->proxy = $proxy; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Whether to encode the curl requests with gzip or not. |
73
|
|
|
* |
74
|
|
|
* @param boolean $gzipEncoding |
75
|
|
|
*/ |
76
|
|
|
public function setGzipEncoding($gzipEncoding) |
77
|
|
|
{ |
78
|
|
|
$this->gzipEncoding = (bool)$gzipEncoding; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Set the size of each part of file for chunked media upload. |
83
|
|
|
* |
84
|
|
|
* @param int $value |
85
|
|
|
*/ |
86
|
|
|
public function setChunkSize($value) |
87
|
|
|
{ |
88
|
|
|
$this->chunkSize = (int)$value; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|