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

CurlIPv4   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 12
rs 10
c 1
b 0
f 0
wmc 3
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 3
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