Api::send()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Franjid\ApiWrapperBundle\Api;
4
5
use GuzzleHttp\ClientInterface;
6
use GuzzleHttp\Exception\RequestException;
7
8
class Api implements ApiInterface
9
{
10
    /** @var ClientInterface $client */
11
    protected $client;
12
13
    /**
14
     * ApiAbstract constructor.
15
     *
16
     * @param ClientInterface $client
17
     */
18 2
    public function __construct(ClientInterface $client)
19
    {
20 2
        $this->client = $client;
21 2
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 2
    public function send(ApiRequestInterface $apiRequest)
27
    {
28
        try {
29 2
            return new ApiResponse(
30 2
                $this->client->send($apiRequest->getRequest(), $apiRequest->getOptions())
31 1
            );
32 1
        } catch (RequestException $exception) {
33 1
            throw new ApiException($exception);
34
        }
35
    }
36
}
37