Config::setChunkSize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 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
    /** @var int How many times we retry request when API is down */
17
    protected $maxRetries = 0;
18
    /** @var int Delay in seconds before we retry the request */
19
    protected $retriesDelay = 1;
20
21
22
23
    /**
24
     * Decode JSON Response as associative Array
25
     *
26
     * @see http://php.net/manual/en/function.json-decode.php
27
     *
28
     * @var bool
29
     */
30
    protected $decodeJsonAsArray = false;
31
    /** @var string User-Agent header */
32
    protected $userAgent = 'TwitterOAuth (+https://twitteroauth.com)';
33
    /** @var array Store proxy connection details */
34
    protected $proxy = [];
35
36
    /** @var bool Whether to encode the curl requests with gzip or not */
37
    protected $gzipEncoding = true;
38
39
    /** @var integer Size for Chunked Uploads */
40
    protected $chunkSize = 250000; // 0.25 MegaByte
41
42
    /**
43
     * Set the connection and response timeouts.
44
     *
45
     * @param int $connectionTimeout
46
     * @param int $timeout
47
     */
48
    public function setTimeouts($connectionTimeout, $timeout)
49
    {
50
        $this->connectionTimeout = (int)$connectionTimeout;
51
        $this->timeout = (int)$timeout;
52
    }
53
54
    /**
55
     *  Set the number of times to retry on error and how long between each.
56
     *
57
     * @param int $maxRetries
58
     * @param int $retriesDelay
59
     */
60
    public function setRetries($maxRetries, $retriesDelay)
61
    {
62
        $this->maxRetries = (int)$maxRetries;
63
        $this->retriesDelay = (int)$retriesDelay;
64
    }
65
66
    /**
67
     * @param bool $value
68
     */
69
    public function setDecodeJsonAsArray($value)
70
    {
71
        $this->decodeJsonAsArray = (bool)$value;
72
    }
73
74
    /**
75
     * @param string $userAgent
76
     */
77
    public function setUserAgent($userAgent)
78
    {
79
        $this->userAgent = (string)$userAgent;
80
    }
81
82
    /**
83
     * @param array $proxy
84
     */
85
    public function setProxy(array $proxy)
86
    {
87
        $this->proxy = $proxy;
88
    }
89
90
    /**
91
     * Whether to encode the curl requests with gzip or not.
92
     *
93
     * @param boolean $gzipEncoding
94
     */
95
    public function setGzipEncoding($gzipEncoding)
96
    {
97
        $this->gzipEncoding = (bool)$gzipEncoding;
98
    }
99
100
    /**
101
     * Set the size of each part of file for chunked media upload.
102
     *
103
     * @param int $value
104
     */
105
    public function setChunkSize($value)
106
    {
107
        $this->chunkSize = (int)$value;
108
    }
109
}
110