File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Cmfcmf/OpenWeatherMap/Fetcher Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 2424 */
2525class CurlFetcher implements FetcherInterface
2626{
27+ /**
28+ * @var array The Curl options to use.
29+ */
30+ private $ curlOptions ;
31+
32+ /**
33+ * Create a new CurlFetcher instance.
34+ *
35+ * @param array $curlOptions The Curl options to use. See http://php.net/manual/de/function.curl-setopt.php
36+ * for a list of available options.
37+ */
38+ public function __construct ($ curlOptions = array ())
39+ {
40+ $ this ->curlOptions = $ curlOptions ;
41+ }
42+
2743 /**
2844 * {@inheritdoc}
2945 */
3046 public function fetch ($ url )
3147 {
3248 $ ch = curl_init ($ url );
33- $ timeout = 5 ;
3449 curl_setopt ($ ch , CURLOPT_URL , $ url );
3550 curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 );
36- curl_setopt ($ ch , CURLOPT_CONNECTTIMEOUT , $ timeout );
51+ curl_setopt ($ ch , CURLOPT_CONNECTTIMEOUT , 5 );
52+ curl_setopt_array ($ ch , $ this ->curlOptions );
53+
3754 $ content = curl_exec ($ ch );
3855 curl_close ($ ch );
3956
You can’t perform that action at this time.
0 commit comments