Completed
Push — master ( 09c641...eb3f62 )
by Narcotic
19:24 queued 04:10
created

GuzzleAdapter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * Guzzle adapter class
4
 */
5
6
namespace Graviton\ProxyBundle\Adapter\Guzzle;
7
8
use GuzzleHttp\Client;
9
use Psr\Http\Message\RequestInterface;
10
use Psr\Http\Message\ResponseInterface;
11
12
/**
13
 *
14
 *
15
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
16
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
17
 * @link     http://swisscom.ch
18
 */
19
class GuzzleAdapter extends Client
20
{
21
22
    /**
23
     * curl options
24
     *
25
     * @var array
26
     */
27
    private $curlOptions;
28
29
    /**
30
     * @inheritDoc
31
     *
32
     * @param RequestInterface $request request
33
     * @param array            $options options
34
     *
35
     * @return ResponseInterface
36
     */
37
    public function send(RequestInterface $request, array $options = [])
38
    {
39
        $opt = array('curl' => []);
40
        foreach ($this->curlOptions as $option => $value) {
41
            $opt['curl'][constant('CURLOPT_'.strtoupper($option))] = $value;
42
        }
43
        $opt['verify'] = __DIR__.'/../../Resources/cert/cacert.pem';
44
        return parent::send($request, array_merge($options, $opt));
45
    }
46
47
    /**
48
     * set curl options
49
     *
50
     * @param array $curlOptions the curl options
51
     *
52
     * @return void
53
     */
54
    public function setCurlOptions(array $curlOptions)
55
    {
56
        $this->curlOptions = $curlOptions;
57
    }
58
}
59