Completed
Push — feature/eco-3656/eco-3658-enab... ( 4f4220...78bea4 )
by
unknown
04:14
created

ComputopToGuzzleHttpClientAdapter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
wmc 3
eloc 10
c 1
b 1
f 1
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A request() 0 9 2
1
<?php
2
3
namespace SprykerEco\Yves\Computop\Dependency\External;
4
5
use GuzzleHttp\ClientInterface;
6
use GuzzleHttp\Exception\GuzzleException;
7
use Psr\Http\Message\ResponseInterface;
8
use Spryker\Yves\Computop\Http\Exception\ComputopHttpRequestException;
9
10
class ComputopToGuzzleHttpClientAdapter implements ComputopToGuzzleHttpClientInterface
11
{
12
    /**
13
     * @var \GuzzleHttp\ClientInterface
14
     */
15
    protected $guzzleHttpClient;
16
17
    /**
18
     * @param \GuzzleHttp\ClientInterface $guzzleHttpClient
19
     */
20
    public function __construct(ClientInterface $guzzleHttpClient)
21
    {
22
        $this->guzzleHttpClient = $guzzleHttpClient;
23
    }
24
25
    /**
26
     * @param string $method
27
     * @param string $uri
28
     * @param array $options
29
     *
30
     * @return ResponseInterface
31
     */
32
    public function request(string $method, string $uri, array $options = []): ResponseInterface
33
    {
34
        try {
35
            return $this->guzzleHttpClient->request($method, $uri, $options);
36
        } catch (GuzzleException $exception) {
37
            throw new ComputopHttpRequestException(
38
                $exception->getMessage(),
39
                $exception->getCode(),
40
                $exception
41
            );
42
        }
43
    }
44
}
45