Completed
Push — master ( a12959...164d8d )
by Mario
03:20
created

NativeRequestManager::request()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 15
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 7
nc 3
nop 1
crap 2
1
<?php
2
3
namespace Marek\Toggable\Http\Manager;
4
5
use Marek\Toggable\API\Exception\Http\BaseException;
6
use Marek\Toggable\API\Exception\NotFoundException;
7
8
/**
9
 * Class NativeRequestManager
10
 * @package Marek\Toggable\Http\Manager
11
 */
12
class NativeRequestManager implements RequestManagerInterface
13
{
14
    /**
15
     * @var \Marek\Toggable\Http\Client\HttpClientInterface
16
     */
17
    private $client;
18
19
    /**
20
     * NativeRequestManager constructor.
21
     *
22
     * @param \Marek\Toggable\Http\Client\HttpClientInterface $client
23
     */
24 17
    public function __construct(\Marek\Toggable\Http\Client\HttpClientInterface $client)
25
    {
26 17
        $this->client = $client;
27 17
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 2
    public function request(\Marek\Toggable\API\Http\Request\RequestInterface $request)
33
    {
34
        try {
35
36 2
            $this->client->prepare($request);
37 2
            $response = $this->client->getResponse();
38
39 2
        } catch (BaseException $e) {
40
41 1
            throw new NotFoundException(get_class($request));
42
43
        }
44
45 1
        return $response;
46
    }
47
}
48