Api::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
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