Completed
Push — master ( e93081...19e3bd )
by Guilherme
04:05
created

CurlIPv4::__construct()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
nc 2
nop 0
dl 0
loc 9
rs 9.6666
c 1
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace PROCERGS\Generic;
12
13
use Buzz\Client\Curl;
14
15
/**
16
 * Class to force the Buzz's Curl client to use only IPv4.
17
 *
18
 * This is needed because we get random errors in some environments
19
 * where cURL tries to make IPv6 requests even when IPv6 is disabled
20
 * in the Operating System.
21
 *
22
 * @package PROCERGS\Generic
23
 */
24
class CurlIPv4 extends Curl
25
{
26
    public function __construct()
27
    {
28
        parent::__construct();
29
30
        // If the fix is available we go for it, otherwise there is nothing we can do.
31
        if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
32
            $this->setOption(CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
33
        }
34
    }
35
}
36